Xgboost throws an error when trying to import

10.6k views Asked by At

I have a project that is using xgboost. We now transfer the project to containers. But after installing it using pip, it throws the following error:

Traceback (most recent call last):
  File "restart_db.py", line 5, in <module>
    from autoai.core.providers import GlobalEnrichmentProvider
  File "/volumes/code/autoai/core/providers/__init__.py", line 1, in <module>
    from .files_providers import CsvProvider, TsvProvider, ExcelProvider, FileProvider
  File "/volumes/code/autoai/core/providers/files_providers.py", line 10, in <module>
    from .base import BaseProvider, BaseInMemoryProvider
  File "/volumes/code/autoai/core/providers/base.py", line 1, in <module>
    from autoai.models.dataset_connection import JoinTypes
  File "/volumes/code/autoai/models/__init__.py", line 5, in <module>
    from .classifier import Classifier
  File "/volumes/code/autoai/models/classifier.py", line 8, in <module>
    from eli5 import explain_prediction
  File "/volumes/dependencies/lib/python3.6/site-packages/eli5/__init__.py", line 53, in <module>
    from .xgboost import (
  File "/volumes/dependencies/lib/python3.6/site-packages/eli5/xgboost.py", line 9, in <module>
    from xgboost import (  # type: ignore
  File "/volumes/dependencies/lib/python3.6/site-packages/xgboost/__init__.py", line 11, in <module>
    from .core import DMatrix, Booster
  File "/volumes/dependencies/lib/python3.6/site-packages/xgboost/core.py", line 150, in <module>
    _LIB = _load_lib()
  File "/volumes/dependencies/lib/python3.6/site-packages/xgboost/core.py", line 141, in _load_lib
    'Error message(s): {}\n'.format(os_error_list))
xgboost.core.XGBoostError: XGBoost Library (libxgboost.so) could not be loaded.
Likely causes:
  * OpenMP runtime is not installed (vcomp140.dll or libgomp-1.dll for Windows, libgomp.so for UNIX-like OSes)
  * You are running 32-bit Python on a 64-bit OS
Error message(s): ['libgomp.so.1: cannot open shared object file: No such file or directory']

I checked that both my python and my ubuntu are 64-bit, and ran: apt-get update && apt-get install -y libaio1

To make sure that package is there (I read it somewhere that this might be the problem) - but it still throws the same error.

I've been stuck on this for a while now and will appreciate any help.

4

There are 4 answers

0
Cheffress On BEST ANSWER

I had the same error with lightGBM, and to get around the issue i ran:

apt-get install libgomp1 

This was required prior to any lightGBM code being called. The error for me occurred when unpickling a lightGBM model, not specifically when importing lightGBM.

0
direbutterfly On

I had the same problem. Tried to fix both "likely" causes to no avail. Strangely, everything was working absolutely fine just a few days ago. I changed the Python version from 3.6.1 to 3.6.7 and it fixed the issue. Unfortunately, I don't yet know what the problem was, but it fixed the issue for me.

This is Python's docker image on CircleCi's linux machine. Specifying this in case the problem has to do anything with it.

Hope this helps someone!

0
Muralitharan Sathyamoorthy On

I had this issue while creating Docker image of my project.

I have used the command below:

RUN apt-get update && \

     apt-get -y --no-install-recommends install \

     libgomp1
0
flow2k On

Got this on my MacOS, and as the debug message suggests, brew install libomp fixed it.