question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Autokeras trying to import libgomp-d22c30c5.so.1.0.0 from scikit-learn on arm64/aarch64

See original GitHub issue

Bug Description

I am trying to use autokeras on a Raspberry Pi 4B with 64-bit Raspberry Pi OS. It can be installed but would generate the following error on import.

Seems like it was trying to import libgomp-d22c30c5.so.1.0.0 from scikit-learn but no such file exists anywhere in the system. Both Tensorflow and scikit-learn can be imported and works properly on their own.

…However, this bug can be bypassed by import sklearn before import autokeras in the same script. Some error about Placeholder_5 would pop up but otherwise the model finished like it should.

Bug Reproduction

>>> import autokeras
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/sklearn/__check_build/__init__.py", line 44, in <module>
    from ._check_build import check_build  # noqa
ImportError: /usr/local/lib/python3.7/dist-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 "<pyshell>", line 1, in <module>
  File "/usr/local/lib/python3.7/dist-packages/autokeras/__init__.py", line 15, in <module>
    from autokeras.auto_model import AutoModel
  File "/usr/local/lib/python3.7/dist-packages/autokeras/auto_model.py", line 25, in <module>
    from autokeras import blocks
  File "/usr/local/lib/python3.7/dist-packages/autokeras/blocks/__init__.py", line 17, in <module>
    from autokeras.blocks.basic import BertBlock
  File "/usr/local/lib/python3.7/dist-packages/autokeras/blocks/basic.py", line 19, in <module>
    from kerastuner.engine import hyperparameters
  File "/usr/local/lib/python3.7/dist-packages/kerastuner/__init__.py", line 20, in <module>
    from . import oracles
  File "/usr/local/lib/python3.7/dist-packages/kerastuner/oracles/__init__.py", line 16, in <module>
    from ..tuners.bayesian import BayesianOptimizationOracle as BayesianOptimization
  File "/usr/local/lib/python3.7/dist-packages/kerastuner/tuners/__init__.py", line 17, in <module>
    from .bayesian import BayesianOptimization
  File "/usr/local/lib/python3.7/dist-packages/kerastuner/tuners/bayesian.py", line 5, in <module>
    from sklearn import exceptions
  File "/usr/local/lib/python3.7/dist-packages/sklearn/__init__.py", line 81, in <module>
    from . import __check_build  # noqa: F401
  File "/usr/local/lib/python3.7/dist-packages/sklearn/__check_build/__init__.py", line 46, in <module>
    raise_build_error(e)
  File "/usr/local/lib/python3.7/dist-packages/sklearn/__check_build/__init__.py", line 41, in raise_build_error
    %s""" % (e, local_dir, ''.join(dir_content).strip(), msg))
ImportError: /usr/local/lib/python3.7/dist-packages/sklearn/__check_build/../../scikit_learn.libs/libgomp-d22c30c5.so.1.0.0: cannot allocate memory in static TLS block
___________________________________________________________________________
Contents of /usr/local/lib/python3.7/dist-packages/sklearn/__check_build:
_check_build.cpython-37m-aarch64-linux-gnu.so__pycache__               __init__.py
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.

Data used by the code:

Expected Behavior

It would be nice if I don’t have to do the additional import before autokeras.

Setup Details

This is how I installed all the stuff on a fresh RPi OS: (I can’t say if all of it is necessary, but right now it works)

sudo apt-get install build-essential python3-dev python3-pip python-h5py python3-h5py libhdf5-dev libblas-dev liblapack-dev libopenblas-dev libatlas-base-dev gfortran -y

sudo pip3 install cython pip setuptools wheel --upgrade

sudo pip3 install numpy==1.18.5

sudo pip3 install wrapt --upgrade --ignore-installed

sudo pip3 install https://github.com/sanjayseshan/tensorflow-aarch64/releases/download/v2.4.0/tensorflow-2.4.0-cp37-cp37m-linux_aarch64.whl

sudo pip3 install autokeras

The aarch64 wheel for autokeras would install/build scipy, pandas and scikit-learn on its own.

  • OS type and version: Debian GNU/Linux 10 (buster), kernel: Linux 5.4.79-v8+, architecture: arm64
  • Python: 3.7.3 (64 bit)
  • autokeras: 1.0.12
  • keras-tuner: 1.0.2
  • scikit-learn: 0.24.0
  • numpy: 1.18.5
  • scipy: 1.5.4
  • pandas: 1.1.5
  • tensorflow: 2.4.0

Hardware is Raspberry Pi 4B 4GB. The 64-bit OS was downloaded from https://ftp.ubuntu-tw.net/mirror/raspbian-downloads/raspios_arm64/images/ and updated/upgraded before installing all the packages above.

Additional context

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
Soninscommented, Nov 18, 2021

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'

For this particular issue,

export LD_PRELOAD='/usr/local/lib/python3.6/dist-packages/scikit_learn.libs/libgomp-d22c30c5.so.1.0.0'

And execute program again.

0reactions
stale[bot]commented, Jul 8, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found