ImportError: Cannot Allocate Memory in Static TLS Block

Reposting this question because I didn’t solve my problem:

I am encountering the following error message when attempting to run my code:

ImportError: /home/orin_nano1/.local/lib/python3.8/site-packages/torch/lib/…/…/torch.libs/libgomp-804f19d4.so.1.0.0: cannot allocate memory in static TLS block

To resolve this, I have tried several solutions, including setting the LD_PRELOAD environment variable with different paths:

export LD_PRELOAD=/home/orin_nano1/.local/lib/python3.8/site-packages/torch/lib/libgomp-d22c30c5.so.1
export LD_PRELOAD=.local/lib/python3.8/site-packages/torch/lib/libgomp-d22c30c5.so.1
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libgomp.so.1

Additionally, I attempted to resolve the issue by reinstalling PyTorch, but none of these solutions have worked.

However, none of these attempts have resolved the issue.

Could anyone provide guidance or suggest other potential fixes for this error?

Thank you in advance for your help!


I just want to confirm that the process I’m following is correct:
In the terminal, I type:nano ~/.bashrc
At the end of the file, I add: export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libgomp.so.1
Then I save the file by pressing Ctrl + O, hitting Enter, and exiting with Ctrl + X.
I run: source ~/.bashrc
Finally, I try to run the code again.
I follow the same steps for these variations:

export LD_PRELOAD=/home/orin_nano1/.local/lib/python3.8/site-packages/torch/lib/libgomp-d22c30c5.so.1

export LD_PRELOAD=.local/lib/python3.8/site-packages/torch/lib/libgomp-d22c30c5.so.1

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

However, for the following cases:

export LD_PRELOAD=.local/lib/python3.8/site-packages/torch/lib/libgomp-d22c30c5.so.1 



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

I receive this error:

ERROR: ld.so: object '/home/orin_nano1/.local/lib/python3.8/site-packages/torch/lib/libgomp-d22c30c5.so.1' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

Let me know if there’s anything I’m missing or if you have any further suggestions.

Hi,

First, could you try if libgomp.so.1 exists in your environment?
This can be done via the following command:

$ sudo find / -iname libgomp.so.1

Then please add the path to the LD_PRELOAD variable accordingly.
Just run the command for the path you found in the above step:

For example:

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

Exporting the variable multiple times will overwrite the value and only the last value can remain.

Thanks.

hank you for the response! I ran sudo find / -iname libgomp.so.1 in the terminal, and it returned a list of paths. The first one was /usr/lib/aarch64-linux-gnu/libgomp.so.1. However, after running export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libgomp.so.1, the issue persists, and I’m still receiving the same error message. Any further suggestions?

Hi,

Would you mind testing the recommendation in the below link:

If it still does not work, could you share your environment(JetPack version) and which PyTorch you tried to install?

Thanks.