Xgboost在尝试导入时出现错误

13

我有一个使用xgboost的项目,现在我们要将其转移到容器中。但是在使用pip安装后,它会抛出以下错误:

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']

我检查了我的Python和Ubuntu都是64位的,并运行了以下命令:

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

为确保该软件包存在(我在某处读到这可能是问题所在),但它仍然抛出相同的错误。

我已经卡在这上面一段时间了,将感激任何帮助。

4个回答

4

我在使用 lightGBM 时也遇到了同样的错误,为了解决这个问题,我运行了以下命令:

apt-get install libgomp1 

在调用任何 lightGBM 代码之前需要执行这个步骤。 对我来说,错误发生在反序列化 lightGBM 模型时,而不是导入 lightGBM 时。


4

在制作我的项目的Docker镜像时,我遇到了这个问题。

我使用了下面的命令:

RUN apt-get update && \

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

     libgomp1

1

我在MacOS上遇到了这个问题,根据调试信息,brew install libomp命令解决了它。


1
我曾经遇到同样的问题。尝试修复了“可能”的两个原因,但都没有成功。奇怪的是,就在几天前一切都运行得非常好。我将Python版本从3.6.1更改为3.6.7,问题得到解决。不幸的是,我还不知道问题出在哪里,但它对我有用。
这是CircleCi的Linux机器上的Python Docker镜像。提供这些信息以防问题与此有关。
希望这能帮助到某人!

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接