Sklearn ImportError cannot allocate memory in static TLS block

I try "import sklearn"command on jupyter notebook.
this command is worked on my Terminal.
I used Jetpack5.1.1 and use “pip install scikit-learn” to install.


ImportError Traceback (most recent call last)
File ~/.local/lib/python3.8/site-packages/sklearn/__check_build/init.py:45
44 try:
—> 45 from ._check_build import check_build # noqa
46 except ImportError as e:

ImportError: /home/keita/.local/lib/python3.8/site-packages/sklearn/__check_build/…/…/scikit_learn.libs/libgomp-d22c30c5.so.1.0.0: cannot allocate memory in static TLS block

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last)
Cell In[10], line 1
----> 1 import sklearn

File ~/.local/lib/python3.8/site-packages/sklearn/init.py:79
68 sys.stderr.write(“Partial import of sklearn during the build process.\n”)
69 # We are not importing the rest of scikit-learn during the build
70 # process, as it may not be compiled yet
71 else:
(…)
77 # later is linked to the OpenMP runtime to make it possible to introspect
78 # it and importing it first would fail if the OpenMP dll cannot be found.
—> 79 from . import (
80 __check_build, # noqa: F401
81 _distributor_init, # noqa: F401
82 )
83 from .base import clone
84 from .utils._show_versions import show_versions

File ~/.local/lib/python3.8/site-packages/sklearn/__check_build/init.py:47
45 from ._check_build import check_build # noqa
46 except ImportError as e:
—> 47 raise_build_error(e)

File ~/.local/lib/python3.8/site-packages/sklearn/__check_build/init.py:31, in raise_build_error(e)
29 else:
30 dir_content.append(filename + “\n”)
—> 31 raise ImportError(“”“%s
32 ___________________________________________________________________________
33 Contents of %s:
34 %s
35 ___________________________________________________________________________
36 It seems that scikit-learn has not been built correctly.
37
38 If you have installed scikit-learn from source, please do not forget
39 to build the package before using it: run python setup.py install or
40 make in the source directory.
41 %s”“” % (e, local_dir, “”.join(dir_content).strip(), msg))

ImportError: /home/keita/.local/lib/python3.8/site-packages/sklearn/__check_build/…/…/scikit_learn.libs/libgomp-d22c30c5.so.1.0.0: cannot allocate memory in static TLS block


Contents of /home/keita/.local/lib/python3.8/site-packages/sklearn/_check_build:
init.py check_build.cpython-38-aarch64-linux-gnu.so__pycache


It seems that scikit-learn has not been built correctly.

If you have installed scikit-learn from source, please do not forget
to build the package before using it: run python setup.py install or
make in the source directory.

If you have used an installer, please check that it is suited for your
Python version, your operating system and your platform.

You may see :

and try to set :

LD_PRELOAD=<wherever_it_is_on_your_filesystem>/scikit_learn.libs/libgomp-d22c30c5.so.1.0.0 python <your_python_app>

Honey_Patouceul
I apologize for my ignorance,but I looked it up and couldn’t figure it out,so could you please explain where <wherever_it_is_on_your_filesystem> represents?

I just meant giving the full path to where is installed the library named libgomp-d22c30c5.so.1.0.0.

If you have no idea where it can be, you can use locate:

sudo apt update
sudo apt install locate

# It may take 2 minutes for the first time, should be quicker next times (don't worry for the few permission denied warings)
sudo updatedb

# This would show matching files:
locate libgomp-d22c30c5.so.1.0.0

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.