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/ :

import tensorflow as tf
from sklearn.preprocessing import StandardScaler


and running like this:

$ python3  # or python

Error log:

Traceback (most recent call last):
  File "/home/.../tfDemo/venvtf/lib/python3.8/site-packages/sklearn/__check_build/", 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/ cannot allocate memory in static TLS block

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 2, in <module>
    from sklearn.preprocessing import StandardScaler
  File "/home/.../tfDemo/venvtf/lib/python3.8/site-packages/sklearn/", line 79, in <module>
    from . import (
  File "/home/.../tfDemo/venvtf/lib/python3.8/site-packages/sklearn/__check_build/", line 47, in <module>
  File "/home/.../tfDemo/venvtf/lib/python3.8/site-packages/sklearn/__check_build/", line 31, in raise_build_error
    raise ImportError("""%s
ImportError: /.../tfDemo/venvtf/lib/python3.8/site-packages/sklearn/__check_build/../../scikit_learn.libs/ cannot allocate memory in static TLS block
Contents of /home/.../tfDemo/venvtf/lib/python3.8/site-packages/sklearn/__check_build:
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 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?


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


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.