How to use both tensorflow and sklearn in virtual environment on jetson agx xavier

I am doing as follow (but I am not sure if it’s right method to use tensorflow and sklearn in jetson module) :

$ python3 -m venv venvtf
$ source venvtf/bin/activate
$ python3 -m pip install setuptools==59.5.0
$ pip3 install tensorflow

$ pip install scikit-learn 
$ export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libgomp.so.1

test.py :

import tensorflow as tf
from sklearn.preprocessing import StandardScaler

print(tf.__version__)

and running like this:

$ python3 test.py  # or python test.py

Error log:

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

Traceback (most recent call last):
  File "test.py", line 2, in <module>
    from sklearn.preprocessing import StandardScaler
  File "/home/.../tfDemo/venvtf/lib/python3.8/site-packages/sklearn/__init__.py", line 79, in <module>
    from . import (
  File "/home/.../tfDemo/venvtf/lib/python3.8/site-packages/sklearn/__check_build/__init__.py", line 47, in <module>
    raise_build_error(e)
  File "/home/.../tfDemo/venvtf/lib/python3.8/site-packages/sklearn/__check_build/__init__.py", line 31, in raise_build_error
    raise ImportError("""%s
ImportError: /.../tfDemo/venvtf/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/.../tfDemo/venvtf/lib/python3.8/site-packages/sklearn/__check_build:
__pycache__               __init__.py               _check_build.cpython-38-aarch64-linux-gnu.so
___________________________________________________________________________
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.

So, Can you let me know if I am doing right,
if yes, how can I solve this problem?
if not, how can I use both Tensorflow and Sklearn in virtual environment in Jetson Agx Xavier module?

Hi,

Do you meet this error only with the virtual environment?
Have you tried to import them on the Jetson native?

Thanks.

No, I haven’t. I am little afraid that it will break other packages.

It’s solved simply by changing package importing order:
import sklearn before importing others.

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