Xgboost throws an error when importing


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.


Can you post your Dockerfile?


I think you need to install libgomp1 package in your container.


I use 2 containers, one of them is holding the dependencies and the other is running the actual code (share the dependencies via volumes to /python3.6/site-packages). Both these docker files have the RUN apt-get update && apt-get install -y libaio1

Dependency dockerfile:

FROM python:3.6-slim

#TODO: Reddis should be in a dockercompose and not all inside one docker
RUN apt-get update && apt-get install -y redis-server \
alien \
unixodbc \
unixodbc-dev \
libaio1 \
libaio-dev \
libsasl2-dev \
libssl-dev \
nfs-common \
libsasl2-dev \
libbz2-dev \


# ODBC Install

COPY drivers/ /volumes/drivers/
WORKDIR /volumes/drivers

# 1. Install the oracle instant client

RUN alien -i oracle-instantclient12.2-basic-
RUN alien -i oracle-instantclient12.2-odbc-

# 2. Setup the client

ENV LD_LIBRARY_PATH /usr/lib/oracle/12.2/client64/lib/
ENV ORACLE_HOME /usr/lib/oracle/12.2/client64/

# 3.
RUN ldconfig

# 4. Not nessesery - I can use the /usr/... directely
RUN ./mysql-connector-odbc-5.3.10-linux-glibc2.12-x86-64bit/bin/myodbc-installer -d -a -n "Oracle 12.2" -t "DRIVER=/usr/lib/oracle/12.2/client64/lib/libsqora.so.12.1"

# Spatial index
WORKDIR /volumes/drivers/spatialindex-src-1.8.5
RUN ./configure
RUN make
RUN make install
RUN ldconfig

WORKDIR /volumes/code/

COPY autoai autoai
COPY config config
COPY autoai autoai

ADD requirements.txt requirements.txt

RUN pip install -r requirements.txt

RUN pip install spacy

CMD tail -f /dev/null

code running dockerfile:
FROM python:3.6-slim

RUN apt-get update && apt-get install -y libaio1 \

WORKDIR /volumes/code/

COPY migrations migrations
COPY templates templates
COPY server.py server.py
COPY restart_db.py restart_db.py
COPY alembic.ini alembic.ini

CMD tail -f /dev/null


Can you install libgomp1 in the second container?