nmslib: Importing nmslib, cannot load any more object with static TLS
I am getting a dlopen error when importing nmslib after tensorflow:
python -c "import tensorflow; print(tensorflow.contrib); import nmslib"
File "<string>", line 1, in <module>
<module 'tensorflow.contrib' from ...>
ImportError: dlopen: cannot load any more object with static TLS
(printing tensorflow contrib simulates importing a module that uses tensorflow, e.g. extending its classes)
switching the order gives no error, and everything works correctly. But in the context of a large code base, it is hard to ensure that nmslib is always imported first, since there are many entry-points. The same thing happens with tensorflow, and it looks similar to this issue: https://stackoverflow.com/questions/50398358/import-error-when-unit-testing-flask-application-with-nmslib
This does not happen on my mac, but only on our Circle CI build, running in a circleci/python:3.6 docker image.
Any suggestions for how to fix this?
I have tried setting the env variable CXXFLAGS="-fPIC -ftls-model=global-dynamic" when pip installing nmslib.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Comments: 15 (6 by maintainers)
Solved for me by placing
import nmslibin the__init__.pyfile of the project