OSError: /usr/lib/aarch64-linux-gnu/libgomp.so.1 ONLY IN JUPYTER NOTEBOOK

I am using the Jetbot 0.4.3 (with Jetpack 4.4.1). I am running the jupyterlab remote connection server.

I get the error

OSError: /usr/lib/aarch64-linux-gnu/libgomp.so.1: cannot allocate memory in static TLS block

when trying to import torch inside jupyter notebook. I am aware that you can use:

export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libgomp.so.1

to fix this issue but it doesn’t work for me. HOWEVER, I get no error if I import torch inside the Python CLI terminal.

What Can I do?

Hi @tmendozarias, if you run % echo $LD_PRELOAD inside your Jupyter notebook, does it show the /usr/lib/aarch64-linux-gnu/libgomp.so.1 path that you set it to? If not, Jupyter must not be picking up that environment variable and maybe you can run % export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libgomp.so.1 at the top of your notebook.

Here is another potential solution to try (just with setting LD_PRELOAD instead of the environment variable that gets set in the issue below):

https://github.com/jupyter/notebook/issues/1290#issuecomment-204388895

It seems that Jupyter spawns a separate process to execute the Python code from the notebook, which is why it’s not picking up the LD_PRELOAD variable that you set before.

1 Like

Hi @dusty_nv . Thanks for the quick reply. Yes, running % echo $LD_PRELOAD does show /usr/lib/aarch64-linux-gnu/libgomp.so.1.

I also tried % export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libgomp.so.1 at the top of the notebook but it still gives error importing torch.

@dusty_nv As i understand, the command c = get_config() is deprecrated. Am I correct? Because i ran it and it told me that get_config() is not defined.

I was able to solve the problem by modifying the service file that runs the jupyterlab for remote connection. I added the export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libgomp.so.1 in the ExecStart line and now it works. Thanks for your help!

1 Like

OK great, glad you were able to get it working! Thanks.

Hello,I want to know the service file you modified is jupyter_notebook_config.py? and where is the ExecStart line? thank you !!

The problem I was having and what I think the OP was talking about was using a service to run the jupyter notebook server. Apparently systemd won’t use the library unless you explicitly tell it in the service file. I had to add

[Service]
Environment=“LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libgomp.so.1”

don’t forget to daemon-reload

2 Likes

I believe it is. Unfortunately I don’t have the Jetson with me but in case you still have issues don’t hesitate to reply through this thread.

thank you! jetson=4.5.1 pytorch=1.8 on jupyter lab , I added it in jupyterlab server $ sudo vim /etc/systemd/system/jupyter.service then it’s working.