Import mxnet throws "ImportError: dlopen: cannot load any more object with static TLS"

I am getting “ImportError: dlopen: cannot load any more object with static TLS” error message when i use import mxnet as mx on python prompt on Ubuntu 14.04. Any idea on what is causing it?

OS: Ubuntu 14.04
Python: 3.6.6
mxnet : 1.3.1

Hi @hemalmas,

Other frameworks have seen similar issues (see TensorFlow and PyTorch), and usually this can be fixed by changing the order of the imports. Can you provide a snippet of imports?

Hi,
I just tried the above on the python prompt by typing command on Ubuntu 14.04 OS

python3

import mxnet as mx

And it throws the reported import error.

Exception trace …

./python3.6
Python 3.6.6 (default, Feb 25 2019, 16:09:45)
[GCC 4.8.4] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import mxnet as mx
Traceback (most recent call last):
File “”, line 1, in
File “/root/python/python3.6.6/lib/python3.6/site-packages/mxnet/init.py”, line 24, in
from .context import Context, current_context, cpu, gpu, cpu_pinned
File “/root/python/python3.6.6/lib/python3.6/site-packages/mxnet/context.py”, line 24, in
from .base import classproperty, with_metaclass, _MXClassPropertyMetaClass
File “/root/python/python3.6.6/lib/python3.6/site-packages/mxnet/base.py”, line 213, in
_LIB = _load_lib()
File “/root/python/python3.6.6/lib/python3.6/site-packages/mxnet/base.py”, line 204, in _load_lib
lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL)
File “/root/python/python3.6.6/lib/python3.6/ctypes/init.py”, line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: dlopen: cannot load any more object with static TLS

Oh, that is strange. And how did you install MXNet? With pip install mxnet? Or build from source?

pip3 install mxnet==1.3.1

Can you try the nightly build and see if you still have the same issues?

pip3 install mxnet --upgrade --pre

And I will try and replicate on Ubuntu 14.04 in the meantime.

I couldn’t reproduce @hemalmas.

I just tried installing mxnet==1.3.1 on Ubuntu 14.04 and I didn’t have any issue with the import. Although I had a slightly different version of Python (3.6.8 instead of 3.6.6) . Can you please try with a virtualenv to remove potential issues with the Python environment.

pip install virtualenv --user
virtualenv --python=python3.6 test_env
source /home/ubuntu/test_env/bin/activate
pip install mxnet==1.3.1
python -c "import mxnet; print(mxnet.__version__)"

Hey everyone,

This is a specific issue with the Glibc version shipped with Ubuntu 14. They specify a small limit on the number of libraries which use thread local storage.

Here is a detailed thread on the issue:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=793641

This will not just affect MXNet, but also other frameworks and programs.

There are two paths I’ve seen. If you upgrade to Ubuntu 16, your Glibc version will be updated and the problem will go away. Another option which may work is to simply try updating libc as per the instructions below. If you do attempt this method, please post whether or not it worked, so that other users can have that information:

Hope that helps!

Hi,
I checked the current version and the candidate version of libc6 on the Ubuntu 14.04 and its same.

sudo apt-cache policy libc6
libc6:
Installed: 2.19-0ubuntu6.14
Candidate: 2.19-0ubuntu6.14

sudo apt-cache policy eglibc-source
eglibc-source:
Installed: 2.19-0ubuntu6.14
Candidate: 2.19-0ubuntu6.14

sudo apt-cache search glibc | grep ‘glibc’
eglibc-source - Embedded GNU C Library: sources
glibc-doc - Embedded GNU C Library: Documentation
glibc-doc-reference - GNU C Library: Documentation
libhybris - Allows to run bionic-based HW adaptations in glibc systems - libs
clisp-module-bindings-glibc - clisp module that adds the glibc bindings
libdb1-compat - Berkeley database routines [glibc 2.0/2.1 compatibility]
libhybris-test - Allows to run bionic-based HW adaptations in glibc systems - tests