-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce the amount of TLS used in pytorch #2083
Comments
this is a known issue when loading multiple libraries ( |
I have fixed it.anyway thx |
How did you fix it? |
the order of import |
Very odd case,I solve it by add one line in the very beginning of my *.py file :
wherever it occurs this error. |
Just like @cc786537662. I solved the problem by putting the line " import torch" in the very beginning of my .py file. |
There are some options proposed here that claim to fix it: https://stackoverflow.com/questions/19268293/matlab-error-cannot-open-with-static-tls . Not sure if any of these might help? FYI I (and our students) can reliably replicate this bug by running lesson1 of the new fastai on Paperspace. It's not a high priority since we can just use AWS instead, but I figured you might be interested in a reliable replication environment. |
@jph00 i am building binaries for I got a paperspace instance and tried to replicate this error. I ran a few notebooks that use pytorch under deeplearning2 but had no luck reproducing so far. Which notebook is reproducing this error for you? Am I looking at the wrong location? |
nevermind, i see that you're talking about https://github.com/fastai/fastai |
@soumith I was having a similar issue, then I added these compile flags |
@htwaijry from what i know the source installs dont have this problem (you dont even need the compile flags). Only the binary installs have this issue. Can you confirm that if you recompiled pytorch from source (without your flags) the problem doesn't exist? |
@soumith You are right, compiling from source without the flags also works. I just went ahead and added those flags when I ran into the problem without trying to compile from source directly without them. |
It is kind of hilarious. When I put cv2 before pytorch I got this error, and when I exchange the position I got the same error as #926 , what can I do? |
@frankenstan the workaround is to do this on your machine:
|
@soumith thx for your reply. Sadly I didn't find it in that directory. |
build pytorch from source can avoid this issue |
I solved this issue by separately Nevertheless, worth a try. |
Use this instruction to update your pytorch to 0.3.0 and you shall solve this problem. |
Fwiw, note that the temporary workaround of putting For example, if a.py imports torch and b.py doesn't import torch but imports functions defined in a.py, then other imports in b.py may happen before the torch import. In my case, I saw that this was happening by noticing that some source files in the stack trace for the "ImportError:dlopen:cannot load any more object with static TLS" didn't even import torch at all. Adding (btw, I had this error and work-around even after the update to 0.3.0.) |
@cc786537662 Thanks for your solution! |
Do we have any resolution for this yet: I am using pip install (have to use /usr/bin/python) method to install torch. I am trying to serve a pytorch application from a docker container using gunicorn. The docker image is having cv2 and therefore when I import torch I am running into this issue. Now, when I change the order of imports, gunicorn goes into an infinite reboot state. By any chance experienced this? |
… TLS' for HPC-validation in SLURM, re: pytorch/pytorch#2083
I just came across this problem when I did
Actually it looked a bit scary since a segment fault occurred after executing
|
In requiring the latest version of PyTorch (v1.0) the loading of it after other imports in tests/conftest.py causes there to be an error during setup of the pytest fixtures ImportError while loading conftest '/home/travis/build/diana-hep/pyhf/tests/conftest.py'. tests/conftest.py:45: in <module> (pyhf.tensor.pytorch_backend(), None), pyhf/tensor/__init__.py:24: in __getattr__ e, E pyhf.exceptions.ImportBackendError: ('There was a problem importing PyTorch. The pytorch backend cannot be used.', ImportError('dlopen: cannot load any more object with static TLS',)) TLS appears to stand for thead local storage * https://stackoverflow.com/questions/19268293/matlab-error-cannot-open-with-static-tls and seems to be a reoccuring issue with PyTorch. The advice for how to deal with it from PyTorch Issue 2083 and 2575 seems to be to simply change the import order so that import torch is always the first import in the files that are causing the issue. The rational for this fix is not understood to me, other then it just makes sure that libraries that (presumably) require a large amount of static TLS are dealt with first. * pytorch/pytorch#2083 * pytorch/pytorch#2575
…feb6b4 Summary: Previous import was dd599b05f424eb161a31f3e059566a33310dbe5e Included changes: - **[355a4954](onnx/onnx@355a4954)**: Update codeowners to have community folder changes assigned to steering committee (pytorch#2104) <Prasanth Pulavarthi> - **[ceaa5da7](onnx/onnx@ceaa5da7)**: Fix Resize/Upsample Shape inference function (pytorch#2085) <Raymond Yang> - **[4de8dc0d](onnx/onnx@4de8dc0d)**: Clarify shape inference requirements for new operators (pytorch#2088) <Hariharan Seshadri> - **[52aa1fad](onnx/onnx@52aa1fad)**: Fix NN defs file (pytorch#2083) <Hariharan Seshadri> Differential Revision: D15924221 fbshipit-source-id: 7b3cb6d8398e1f3dcd95aaf6293dd9cfc3a8f5b6
…feb6b4 (#22030) Summary: Pull Request resolved: #22030 Previous import was dd599b05f424eb161a31f3e059566a33310dbe5e Included changes: - **[355a4954](onnx/onnx@355a4954)**: Update codeowners to have community folder changes assigned to steering committee (#2104) <Prasanth Pulavarthi> - **[ceaa5da7](onnx/onnx@ceaa5da7)**: Fix Resize/Upsample Shape inference function (#2085) <Raymond Yang> - **[4de8dc0d](onnx/onnx@4de8dc0d)**: Clarify shape inference requirements for new operators (#2088) <Hariharan Seshadri> - **[52aa1fad](onnx/onnx@52aa1fad)**: Fix NN defs file (#2083) <Hariharan Seshadri> Reviewed By: bddppq Differential Revision: D15924221 fbshipit-source-id: 91ba64ef3e1a2de4a7dd0b02ee6393508cc44a73
…feb6b4 (pytorch#22030) Summary: Pull Request resolved: pytorch#22030 Previous import was dd599b05f424eb161a31f3e059566a33310dbe5e Included changes: - **[355a4954](onnx/onnx@355a4954)**: Update codeowners to have community folder changes assigned to steering committee (pytorch#2104) <Prasanth Pulavarthi> - **[ceaa5da7](onnx/onnx@ceaa5da7)**: Fix Resize/Upsample Shape inference function (pytorch#2085) <Raymond Yang> - **[4de8dc0d](onnx/onnx@4de8dc0d)**: Clarify shape inference requirements for new operators (pytorch#2088) <Hariharan Seshadri> - **[52aa1fad](onnx/onnx@52aa1fad)**: Fix NN defs file (pytorch#2083) <Hariharan Seshadri> Reviewed By: bddppq Differential Revision: D15924221 fbshipit-source-id: 91ba64ef3e1a2de4a7dd0b02ee6393508cc44a73
With a more recent version of scikit learn, our gcc5.4 build is affected by this:
|
this error appeared when I upgrade torch from 1.1 to 1.2 |
To consolidate, I'm closing this as a dupe of #2575 |
Merging pytorch (6aa1f4e) caused > OSError: dlopen: cannot load any more object with static TLS on Debian 8 and Ubuntu Trusty. This is a known issue with pytorch, see e.g. pytorch/pytorch#2083 scikit-learn/scikit-learn#14485 pytorch/pytorch#2575 https://stackoverflow.com/questions/14892101/cannot-load-any-more-object-with-static-tls Apparently there might be a workaround involving reordering import statements, but the root issue is that pytorch doesn't get testing on "obscure" platforms. Including pytorch means we can't reliably support them.
Merging pytorch (6aa1f4e) caused > OSError: dlopen: cannot load any more object with static TLS on Debian 8 and Ubuntu Trusty. This is a known issue with pytorch, see e.g. pytorch/pytorch#2083 scikit-learn/scikit-learn#14485 pytorch/pytorch#2575 https://stackoverflow.com/questions/14892101/cannot-load-any-more-object-with-static-tls Apparently there might be a workaround involving reordering import statements, but the root issue is that pytorch doesn't get testing on "obscure" platforms. Including pytorch means we can't reliably support them.
This error occurs after I upgrade the version of GCC with some wrong setting.
Btw, I don't know the reason, and hope for futher disscussion. |
…#2083) Co-authored-by: Xiang Gao <qasdfgtyuiop@gmail.com>
when I run the code:https://github.com/bear63/sceneReco
I shows thatImportError:dlopen:cannot load any more object with static TLS
The text was updated successfully, but these errors were encountered: