user14490575
user14490575

Reputation:

After using pip, I get the error "Scikit-learn has not been built correctly"

I'm using a Jetson Nano and I already tried reinstalling tensorflow (tried different versions) and numpy (also different versions). I'm using the pip3 commands, since I'm using python3 (version 3.6.9). Downgrading everything didn't work, since Keras needs tensorflow >2.2 I also tried reinstalling scikit-learn, using the --force-reinstall flag. Since it might be helpful, here is the full error message I receive when trying to run my program:

    Traceback (most recent call last):
  File "/home/nano/.local/lib/python3.6/site-packages/sklearn/__check_build/__init__.py", line 44, in <module>
    from ._check_build import check_build  # noqa
ImportError: /home/nano/.local/lib/python3.6/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:

Traceback (most recent call last):
  File "LSTMMVMSTSF.py", line 4, in <module>
    import sklearn
  File "/home/nano/.local/lib/python3.6/site-packages/sklearn/__init__.py", line 81, in <module>
    from . import __check_build  # noqa: F401
  File "/home/nano/.local/lib/python3.6/site-packages/sklearn/__check_build/__init__.py", line 46, in <module>
    raise_build_error(e)
  File "/home/nano/.local/lib/python3.6/site-packages/sklearn/__check_build/__init__.py", line 41, in raise_build_error
    %s""" % (e, local_dir, ''.join(dir_content).strip(), msg))
ImportError: /home/nano/.local/lib/python3.6/site-packages/sklearn/__check_build/../../scikit_learn.libs/libgomp-d22c30c5.so.1.0.0: cannot allocate memory in static TLS block
___________________________________________________________________________
Contents of /home/nano/.local/lib/python3.6/site-packages/sklearn/__check_build:
__init__.py               _check_build.cpython-36m-aarch64-linux-gnu.so__pycache__
setup.py
___________________________________________________________________________
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.

Edit: I forgot to add information on the installation of scikit-learn. I used sudo pip3 install scikit-learn. The logs of that installment:

sudo pip3 install scikit-learn  Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Collecting scikit-learn
  Downloading scikit_learn-0.24.2-cp36-cp36m-manylinux2014_aarch64.whl (24.0 MB)
     |████████████████████████████████| 24.0 MB 20.5 MB/s
Requirement already satisfied: threadpoolctl>=2.0.0 in /home/nano/.local/lib/python3.6/site-packages (from scikit-learn) (2.1.0)
Requirement already satisfied: joblib>=0.11 in /home/nano/.local/lib/python3.6/site-packages (from scikit-learn) (1.0.1)
Requirement already satisfied: numpy>=1.13.3 in /home/nano/.local/lib/python3.6/site-packages (from scikit-learn) (1.19.0)
Requirement already satisfied: scipy>=0.19.1 in /home/nano/.local/lib/python3.6/site-packages (from scikit-learn) (1.5.4)
Installing collected packages: scikit-learn
Successfully installed scikit-learn-0.24.2

Upvotes: 2

Views: 11005

Answers (4)

Jawad Chughtai
Jawad Chughtai

Reputation: 33

I faced this issue when another package "sentence_transformer" I am using used "scikit-learn" in one of my Python Django projects. For me, the solution was to import SentenceTransformer at the top of the manage.py file.

This is the link to where I got this idea from

Upvotes: 0

Sonins
Sonins

Reputation: 303

For those who cannot change import order (For example, library which uses sklearn raises error), I resolved this problem by setting environment variable LD_PRELOAD to path to libgomp-d22c30c5.so.1.0.0.

export LD_PRELOAD='/PATH/TO/libgomp-d22c30c5.so.1.0.0'

And execute program again.

Upvotes: 4

user14490575
user14490575

Reputation:

I found the answer in another post:

There is no actual issue with installing, the order of imports just needs to be changed. In my case, I had to make sklearn the first import. Further reading here

Upvotes: 5

Swaroop Bhandary
Swaroop Bhandary

Reputation: 348

You need to install the tensorflow whl specific to aarch64 architecture. The prebuilt tensorflow binaries for aarch64 are provided by nvidia at the following location

https://developer.download.nvidia.com/compute/redist/jp/v44/

This link is for jetpack 4.4 (v44). Update the link based on the jetpack version you are using.

Upvotes: 0

Related Questions