为什么 xgboost 工作/不工作取决于其他软件包的导入顺序?

发布于 2025-01-16 19:49:26 字数 1435 浏览 3 评论 0原文

当尝试使用以下命令导入 xgboost 时:

import pandas as pd,  numpy as np, psycopg2, xgboost as xgb, os, shutil, pickle, random

我收到以下错误:

  File "/opt/virtual_environments/ml_venv/lib/python3.6/site-packages/xgboost/__init__.py", line 9, in <module>
    from .core import DMatrix, DeviceQuantileDMatrix, Booster, DataIter
  File "/opt/virtual_environments/ml_venv/lib/python3.6/site-packages/xgboost/core.py", line 203, in <module>
    _LIB = _load_lib()
  File "/opt/virtual_environments/ml_venv/lib/python3.6/site-packages/xgboost/core.py", line 194, in _load_lib
    """)
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
    - libomp.dylib for Mac OSX
    - libgomp.so for Linux and other UNIX-like OSes
    Mac OSX users: Run `brew install libomp` to install OpenMP runtime.

  * You are running 32-bit Python on a 64-bit OS

Error message(s): ['dlopen: cannot load any more object with static TLS']

在 psycopg2 前面切换 xgboost 的导入,如下所示:

import pandas as pd,  numpy as np, xgboost as xgb, psycopg2, os, shutil, pickle, random

代码导入,找到共享库并运行良好。

我知道这可能取决于服务器/环境的设置,但是首先导入 xgboost 时它的工作是否有某种原因? psycopg2 是否可能更改系统路径或环境变量?

干杯

When trying to import xgboost with the following:

import pandas as pd,  numpy as np, psycopg2, xgboost as xgb, os, shutil, pickle, random

I get the following error:

  File "/opt/virtual_environments/ml_venv/lib/python3.6/site-packages/xgboost/__init__.py", line 9, in <module>
    from .core import DMatrix, DeviceQuantileDMatrix, Booster, DataIter
  File "/opt/virtual_environments/ml_venv/lib/python3.6/site-packages/xgboost/core.py", line 203, in <module>
    _LIB = _load_lib()
  File "/opt/virtual_environments/ml_venv/lib/python3.6/site-packages/xgboost/core.py", line 194, in _load_lib
    """)
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
    - libomp.dylib for Mac OSX
    - libgomp.so for Linux and other UNIX-like OSes
    Mac OSX users: Run `brew install libomp` to install OpenMP runtime.

  * You are running 32-bit Python on a 64-bit OS

Error message(s): ['dlopen: cannot load any more object with static TLS']

Switching the import of xgboost in front of psycopg2 like so:

import pandas as pd,  numpy as np, xgboost as xgb, psycopg2, os, shutil, pickle, random

The code imports, finds the shared libraries and runs fine.

I know this could be dependent on the setup of the server/environment, but is there some reason why its working when xgboost is imported first? Is psycopg2 potentially changing system paths or environment variables?

Cheers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文