Xgboost: 点安装失败

创建于 2015-09-02  ·  72评论  ·  资料来源: dmlc/xgboost

root@0c6c17725a7b :/# pip install xgboost
下载/解压 xgboost
找不到满足 xgboost 要求的版本(来自版本:0.4a12、0.4a13)
打扫干净...
没有与 xgboost 版本匹配的发行版
在 /root/.pip/pip.log 中存储失败的调试日志

您可以在 docker 中重复:
docker run -it --rm ubuntu: trusty

apt-get update
apt-get install python-pip
pip install xgboost

另见:

http://stackoverflow.com/questions/32258463/install-xgboost-under-python-failing

最有用的评论

我不得不从头开始构建它:

git clone --recursive https://github.com/dmlc/xgboost.git  
cd xgboost  
./build.sh
pip install -e python-package  

所有72条评论

似乎对我不起作用

ubuntu@ip-172-31-11-169 :~$ sudo apt-get update
... 亚达亚达
ubuntu@ip-172-31-11-169 :~$ sudo apt-get install python-pip
阅读包裹清单...完成
构建依赖树
读取状态信息...完成
python-pip 已经是最新版本了。
0 升级,0 新安装,0 删除和 74 未升级。
ubuntu@ip-172-31-11-169 :~$ sudo pip install xgboost
下载/解压 xgboost
找不到满足 xgboost 要求的版本(来自版本:0.4a12、0.4a13)
打扫干净...
没有与 xgboost 版本匹配的发行版
在 /home/ubuntu/.pip/pip.log 中存储失败的调试日志
ubuntu@ip-172-31-11-169 :~$

--pre 的stackoverflow建议产生了这个:

ubuntu@ip-172-31-11-169 :~$ sudo pip install --pre xgboost
下载/解压 xgboost
下载 xgboost-0.4a13.tar.gz (690kB):已下载 690kB
为包 xgboost 运行 setup.py (path:/tmp/pip_build_root/xgboost/setup.py) egg_info
xgboost/build-python.sh:13:xgboost/build-python.sh:pushd:未找到
make: * 没有使目标python'. Stop. ----------------------------- Building multi-thread xgboost failed Start to build single-thread xgboost make: *** No rule to make target干净的规则。
停止。成功搭建单线程xgboost如果你想要多线程版本请参阅 doc/build.md 中的其他说明xgboost/build-python.sh:26:xgboost/build-python.sh:popd:未找到(无,无)回溯(最近一次通话最后):文件 ”",第 17 行,在


init .py”,第 8 行,在








self._handle = _dlopen(self._name, mode)
OSError:/tmp/pip_build_root/xgboost/xgboost/./wrapper/libxgboostwrapper.so:无效的 ELF 标头
命令 python setup.py egg_info 的完整输出:
xgboost/build-python.sh:13:xgboost/build-python.sh:pushd:未找到

make: *** 没有规则来制作目标“python”。 停止。


构建多线程 xgboost 失败

开始搭建单线程xgboost

make: *** 没有使目标“干净”的规则。 停止。

make: *** 没有规则来制作目标“python”。 停止。

成功搭建单线程xgboost

如果你想要多线程版本

请参阅 doc/build.md 中的其他说明

xgboost/build-python.sh:26:xgboost/build-python.sh:popd:未找到

(无,无)

回溯(最近一次通话最后):

文件 ”",第 17 行,在

文件“/tmp/pip_build_root/xgboost/setup.py”,第 20 行,在

import xgboost

文件“ ./xgboost/init .py”,第 8 行,在

from .core import DMatrix, Booster

文件“./xgboost/core.py”,第 78 行,在

_LIB = _load_lib()

_load_lib 中的文件“./xgboost/core.py”,第 72 行

lib = ctypes.cdll.LoadLibrary(lib_path[0])

LoadLibrary 中的文件“/usr/lib/python2.7/ctypes/init .py ”,第 443 行

return self._dlltype(name)

文件“/usr/lib/python2.7/ctypes/init .py”,第 365,在init

self._handle = _dlopen(self._name, mode)

OSError:/tmp/pip_build_root/xgboost/xgboost/./wrapper/libxgboostwrapper.so:无效的 ELF 标头


打扫干净...
命令 python setup.py egg_info 在 /tmp/pip_build_root/xgboost 中失败,错误代码为 1
在 /home/ubuntu/.pip/pip.log 中存储失败的调试日志
ubuntu@ip-172-31-11-169 :~$

@cliveseldon @grfiv pip 安装的版本有些混乱,因为0.4 正式版已经存在很久了,pip 安装包含一些最近的源代码更新,所以我将版本命名为0.4a12 0.4a13某物。 稍后将在下一个正式版本中进行更正。

更新pip安装的一个很好的解决方案是,从站点包目录中删除xgboost目录和xgboost-0.4a13.dist-info目录,例如/User/phunterlau/python2.7/site-packages/ (安装位置可以从print xgboost.__file__找到

你好,
我的 ubuntu 机器上也有同样的问题:

跑步 :

sudo -H pip install --pre xgboost
python -c "import xgboost"

失败如下:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/xgboost/__init__.py", line 11, in <module>
    from .core import DMatrix, Booster
  File "/usr/local/lib/python2.7/dist-packages/xgboost/core.py", line 92, in <module>
    _LIB = _load_lib()
  File "/usr/local/lib/python2.7/dist-packages/xgboost/core.py", line 86, in _load_lib
    lib = ctypes.cdll.LoadLibrary(lib_path[0])
  File "/usr/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary
    return self._dlltype(name)
  File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /usr/local/lib/python2.7/dist-packages/xgboost/./wrapper/libxgboostwrapper.so: invalid ELF header

我也试过没有--pre ,它同样失败。

有什么线索吗?
谢谢,
F。

我使用 pip install xgboost 在 mac OSX 上安装 xgboost-0.4a14。 当我尝试加载它时,我得到了这个错误。

OSError Traceback(最后一次调用)
()
----> 1 将 xgboost 导入为 xgb

/Users/azaitzeff/anaconda/lib/python2.7/site-packages/xgboost/ init .py()
9 导入操作系统
10
---> 11 from .core import DMatrix, Booster
12 来自 .training 进口火车,简历
13 从 .sklearn 导入 XGBModel、XGBClassifier、XGBRegressor

/Users/azaitzeff/anaconda/lib/python2.7/site-packages/xgboost/core.py 在()
90
91 # 全局加载 XGBoost 库
---> 92 _LIB = _load_lib()
93
94 def_check_call(ret):

/Users/azaitzeff/anaconda/lib/python2.7/site-packages/xgboost/core.py 在 _load_lib()
84 如果 len(lib_path) == 0:
85 返回无
---> 86 lib = ctypes.cdll.LoadLibrary(lib_path[0])
87 lib.XGBGetLastError.restype = ctypes.c_char_p
88 返回库

/Users/azaitzeff/anaconda/lib/python2.7/ctypes/ 在 LoadLibrary(self, name) 中初始化.pyc
441
第442章
--> 443 返回 self._dlltype(name)
444
第445章

/Users/azaitzeff/anaconda/lib/python2.7/ctypes/ init .pyc in init (self, name, mode, handle, use_errno, use_last_error)
363
364 如果句柄为无:
--> 365 self._handle = _dlopen(self._name, mode)
366 其他:
第367章

OSError:dlopen(/Users/azaitzeff/anaconda/lib/python2.7/site-packages/xgboost/./wrapper/libxgboostwrapper.so,6):未加载库:/usr/local/lib/gcc/4.9/libgomp .1.dylib
引用自:/Users/azaitzeff/anaconda/lib/python2.7/site-packages/xgboost/./wrapper/libxgboostwrapper.so
原因:找不到图片

任何帮助。 谢谢
AZ

@AZaitzeff @Fkawala谢谢。 您能否确认您的 ubuntu 或 Mac 上是否安装了 gcc? 根据您的信息,我看到了预编译库的问题:如果系统上没有安装 gcc,则 pip 中的构建脚本会失败。 但是,在 pip 安装包中,我包含了一个使用来自 Mac 的 brew 的 gcc 4.9 的预编译库 libxgboostwrapper.so,因此如果构建脚本失败,xgboost 将搜索这个预编译库。 Linux 无法识别这个 Mac lib,所以它有 ELF 代码错误; 对于没有 OpenMP 的 mac,它会触发链接错误。 现在我看到它会引起一些混乱,这可能不是一个好主意。 我将更新 pip 安装,如果没有 gcc 则显示消息。 PS 我们将在下一个正式版本中提供预编译和静态链接的库,这是一个更好的预编译代码交付解决方案。

@phunterlau谢谢。 我的 Mac 上没有 OpenMP。 这就是导致错误的原因。

@phunterlau好的,我将设置一个适当的编译环境并再次测试 pip 安装。

感谢您的快速回复。

所以我运行了 brew install clang-omp 并安装了它。 删除了 xgboost 目录和 xgboost-0.4a13.dist-info 并重新运行 pip install xgboost。 关闭我的终端窗口并重新打开它们。 但是我在尝试导入 xgboost 时仍然遇到同样的错误。 有什么想法吗?

@AZaitzeff实际上不推荐 clang-omp,因为来自 Xcode 的 clang 不支持它,所以 clang-omp 可能会给出一些奇怪的结果。 mac pip 安装包是使用 OpenMP 在 brew 的 gcc 4.9 上创建和测试的。 你想试试brew install gcc49吗? 现在我们也有来自 brew 的 gcc 5,但我还没有机会对其进行全面测试。 我将在下一个 pip 上传中进行。

谢谢,效果很好。

@phunterlau构建(使用./xgboost/build-python.sh )就像一个魅力。 但是,pip 安装会生成预编译的库。 我修改setup.py来说明为什么不尝试编译。 使用 PIP 7.1.2 (python 2.7),运行:

pip install --user -e ./tweaked-xgboost-0.4a13/

给出:

'pip' in __file__: False
not os.name == 'nt': True

根据http://stackoverflow.com/questions/9959279/detect-pip-in-setup-py [1] 'pip' in __file__测试不适用于 Py 2.7 2014-10-27 或自定义安装(正如我在之前的评论中使用的那样)。 正如 [1] 中提出的, 'pip' in os.environ.get('_')是一种更标准的方法来测试 pip 是否运行setup.py

@Fkawala谢谢。 'pip' in __file__是很久以前的老把戏了,很高兴知道新的。 我将更新 pip 安装并稍后发送 PR(带有其他一些补丁)。

@phunterlau我有类似的问题,不明白如何解决这个 ELF 错误。 我正在使用 ubuntu 并且在使用 pip 安装后无法导入 xgboost 包。 您写了关于 gcc 的文章,我安装了 gcc-4.9,但仍然无法正常工作,我缺少什么?

这是我的错误:

导入 xgboost

OSError Traceback(最后一次调用)
()
----> 1 导入 xgboost
/home/antklen/anaconda/lib/python2.7/site-packages/xgboost/ init .py()
9 导入操作系统
10
---> 11 from .core import DMatrix, Booster
12 来自 .training 进口火车,简历
13 从 .sklearn 导入 XGBModel、XGBClassifier、XGBRegressor
/home/antklen/anaconda/lib/python2.7/site-packages/xgboost/core.py 在()
90
91 # 全局加载 XGBoost 库
---> 92 _LIB = _load_lib()
93
94 def_check_call(ret):
/home/antklen/anaconda/lib/python2.7/site-packages/xgboost/core.py 在 _load_lib()
84 如果 len(lib_path) == 0:
85 返回无
---> 86 lib = ctypes.cdll.LoadLibrary(lib_path[0])
87 lib.XGBGetLastError.restype = ctypes.c_char_p
88 返回库
/home/antklen/anaconda/lib/python2.7/ctypes/__init__.pyc 在 LoadLibrary(self, name)
441
第442章
--> 443 返回 self._dlltype(name)
444
第445章
/home/antklen/anaconda/lib/python2.7/ctypes/__init__.pyc in init (self, name, mode, handle, use_errno, use_last_error)
363
364 如果句柄为无:
--> 365 self._handle = _dlopen(self._name, mode)
366 其他:
第367章
OSError:/home/antklen/anaconda/lib/python2.7/site-packages/xgboost/./wrapper/libxgboostwrapper.so:无效的 ELF 标头

@antklen在 Windows 中,您需要先安装 setuptools。 我不确定ubuntu是否是这种情况,但也许值得一试?

@antklen这是因为当前的 pip 安装是一个即时编译器脚本,并且它附带一个 Mac 版本的 .so 文件,以防某些 mac 用户没有安装 g++ 进行编译。 结果证明这不是一个好主意,并给 Linux 用户造成了一些困惑。

解决方案是,请安装 gcc 和 g++ apt-get install g++ ,这样它就会拾取编译脚本。

而且,如果您的 pip 比 0.7.1.2 更新,它可能还有另一个检查 pip 是否正在运行的问题。 我将在下一个版本中修复并发布它。 如果您有 g++ 但仍然出现相同的错误,请按照安装文档手动从 setup.py 安装。

@smargsongithub @phunterlau感谢您的回复!
apt-get install g++ 也对我不起作用,但我按照此处所述手动安装成功https://www.kaggle.com/c/springleaf-marketing-response/forums/t/16320/cloud-vs-本地机器的优缺点
我遇到了一些问题,因为我使用的是 Anaconda,所以我的最终配方是

sudo apt-get install make
sudo apt-get 更新
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get 安装 git
sudo git clone https://github.com/dmlc/xgboost
cd xgboost
须藤 ./build.sh
cd python 包
sudo /home/用户名/anaconda/bin/python setup.py install

@antklen哦,安装 g++ 时需要 sudo :-)

@Fkawala我正在尝试'pip' in os.environ.get('_')更新点子,但是os.environ.get('_')总是返回None并且这个 if 语句给出了错误。 我们是否有其他方法来检测命令行中的 pip 是否存在? 否则,我会为 pip 创建一个单独的setup.py并在那里触发编译器。 谢谢。

@phunterlau我从 pip install xgboost 得到以下回溯,有什么想法吗? (运行 Mac)

回溯(最近一次通话最后):
文件 ”",第 20 行,在
文件“/private/var/folders/7g/thc6mmqd2nb55r21htwx2slr0000gp/T/pip-build-0BlCW9/xgboost/setup.py”,第 38 行,在
LIB_PATH = libpath 'find_lib_path'
文件“/private/var/folders/7g/thc6mmqd2nb55r21htwx2slr0000gp/T/pip-build-0BlCW9/xgboost/xgboost/libpath.py”,第 47 行,在 find_lib_path
'c 候选者列表:n ' + ('n'.join(dll_path)))
内置.XGBoostLibraryNotFound:在候选路径中找不到 XGBoost 库,您是否在根路径中运行 build.sh?
候选人名单:
/private/var/folders/7g/thc6mmqd2nb55r21htwx2slr0000gp/T/pip-build-0BlCW9/xgboost/xgboost/libxgboostwrapper.so
/private/var/folders/7g/thc6mmqd2nb55r21htwx2slr0000gp/T/pip-build-0BlCW9/xgboost/xgboost/../../wrapper/libxgboostwrapper.so
/private/var/folders/7g/thc6mmqd2nb55r21htwx2slr0000gp/T/pip-build-0BlCW9/xgboost/xgboost/./wrapper/libxgboostwrapper.so
/private/var/folders/7g/thc6mmqd2nb55r21htwx2slr0000gp/T/pip-build-0BlCW9/xgboost/xgboost/../../../xgboost/wrapper/libxgboostwrapper.so


命令“python setup.py egg_info”在 /private/var/folders/7g/thc6mmqd2nb55r21htwx2slr0000gp/T/pip-build-0BlCW9/xgboost 中失败,错误代码为 1

@pcohen89这个 python 包附带 C++ 代码并即时编译,因此您可能需要一个编译器。 您是否安装了编译器,例如来自 Xcode 的 gcc-5 或 clang LLVM? Mac 默认不安装 xcode 命令行工具,您可以按照此说明操作http://railsapps.github.io/xcode-command-line-tools.html或者,另一个更好的选择是安装homebrew http ://brew.sh/brew install g++-5 。 后一个选项 (g++-5) 提供多线程 OpenMP 支持。

安装编译器后,请移除旧的 xgboost 安装,并重做pip install xgboost

@antklen @phunterlau按照@antklen提到的步骤进行了尝试。 现在,我可以在终端上运行 import xgboost 了。 但是在 anacondas ipython notebook 上,它给了我以下错误。 请提供任何帮助。 我正在使用 ubuntu。

XGBoostLibraryNotFound: Cannot find XGBoost Libarary in the candicate path, did you run build.sh in root path?
List of candidates:
/home/simpl/anaconda/lib/python2.7/site-packages/xgboost-0.4-py2.7.egg/xgboost/libxgboostwrapper.so
/home/simpl/anaconda/lib/python2.7/site-packages/xgboost-0.4-py2.7.egg/xgboost/../../wrapper/libxgboostwrapper.so
/home/simpl/anaconda/lib/python2.7/site-packages/xgboost-0.4-py2.7.egg/xgboost/./wrapper/libxgboostwrapper.so

@Jeechu这意味着 xgboost 没有编译,你有没有:

  1. 删除了旧的 xgboost 安装?
  2. 安装了 xcode (mac) 还是 gcc-5 (Mac 使用 brew,linux 使用 apt-get 或 yum)?

pip install xgboost -v可以告诉更多关于错误信息的信息。

@phunterlau我和@Jeechu我们已经删除了旧的 xgboost 安装并安装了 gcc、g++。 XGBoost 通过终端运行良好,但使用 anaconda ipython notebook 时会出现该错误。

安装路径有问题吗?

@rajdeltarobo @Jeechu你的 ipython 笔记本的 python 版本是什么? 并且,.bashrc(或您的外壳中的其他环境文件)中的$PYTHONPATH变量是什么?

似乎您的 xgboost 正在搜索/home/simpl/anaconda/lib/python2.7/site-packages/xgboost-0.4-py2.7.egg/这不是 pip 安装路径(pip 安装有其附加版本号,例如 xgboost-0.4a24),因此 ipython 笔记本尝试从python setup.py install搜索您的 xgboost来自github,因此问题可能来自$PYTHONPATH

@phunterlau $PYTHONPATH未定义,它返回一个空白。 但是,下面是路径的值

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/simpl/anaconda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

蟒蛇路径是

➜  ~  which python  
/usr/bin/python

ipython notebook的python版本是2.7

将这样的内容添加到您的 PYTHONPATH 怎么样:
/Users/simpl/anaconda/lib/python2.7/site-packages/

如果你想使用 anaconda 的 python,一切都用它,否则使用virtualenv而不是安装多个 python。 如果在同一台机器上安装了多个 python 会很混乱。

@phunterlau不工作。 我正在使用 ubuntu 所以添加

/home/user/anaconda/lib/python2.7/site-packages/

虽然,我可以在 Bashrc 文件的末尾看到这个

# added by Anaconda 2.3.0 installer
export PATH="/home/user/anaconda/bin:$PATH"

@phunterlau我已经安装了 gcc 并认为这就足够了。 得到了 Xcode,这一切都奏效了。 感谢大家对 Xgboost 的支持,这太棒了,你们都非常乐于助人。

@pcohen89很高兴知道 xcode 有帮助。 您可能会发现 xcode clang 仅支持单线程 xgboost,因此您可能想尝试brew install g++-5以获得多线程支持。 无论如何,工作副本是一个很好的副本。

@rajdeltarobo PATH 与 PYTHONPATH 不同,其中 PYTHONPATH 允许 python 找到自定义的包安装。 请添加它并获取您的 bashrc。

将 /wrapper/libxgboostwrapper.so 复制到 /home/username/anaconda3/lib/python3.4/site-packages/xgboost-0.4-py3.4.egg/xgboost/ 为我解决了这个问题(我使用的是 Ubuntu 14.04)

我的问题是:

XGBoostLibraryNotFound:在候选路径中找不到 XGBoost 库,您是否在根路径中运行了 build.sh?
候选人名单:
/home/simpl/anaconda/lib/python2.7/site-packages/xgboost-0.4-py2.7.egg/xgboost/libxgboostwrapper.so
/home/simpl/anaconda/lib/python2.7/site-packages/xgboost-0.4-py2.7.egg/xgboost/../../wrapper/libxgboostwrapper.so
/home/simpl/anaconda/lib/python2.7/site-packages/xgboost-0.4-py2.7.egg/xgboost/./wrapper/libxgboostwrapper.so

@davutpolat您消息中的错误来自最近为 pip 安装解决冲突所做的更改,但结果证明更改不是一个好主意,因此我们将其回滚(PR #572)。 将来,不需要此副本,我们将有另一个单独的设置配置,仅用于 pip 安装和动态编译。 很抱歉这两天给您带来的不便。

我正在尝试通过 pip 安装 xgboost,但由于与@davutpolat相同的错误而失败。 我想使用他的解决方案,但我不知道在哪里可以找到 /wrapper/libxgboostwrapper.so。

@claygirl你的系统中有 gcc 或 clang 吗? 还请告诉您的系统环境和错误消息

解决方案。 我有同样的 OSError: /usr/local/lib/libxgboostwrapper.so: cannot open shared object file: No such file or directory。 我复制了
site-packages/xgboost-0.4-py2.7.egg/xgboost/./wrapper/libxgboostwrapper.so 到 /usr/local/lib/ 并且似乎工作。
但对它不满意,因为我有 2.7 和 3.4。 ..任何新的决议?

@dsivakumar site-packages/xgboost-0.4-py2.7.egg/xgboost/./wrapper 是 libxgboostwrapper.so 的预期位置,如果使用 pip 安装,并且 xgboost/lib_path.py 已包含此路径,因此import xgboost可以很容易地找到它。 如果你想要 2.7 和 3.4,请使用 virtualenv 并单独安装 pip,因为 pip 取决于 python 版本。

@phunterlau谢谢,这似乎是唯一的解决方案。

我尝试了几次但失去了在我的 Windows 操作系统 PC 上安装 xgboost 的希望,
但现在可能是你会帮助做什么
这是错误
C:UsersSander>pip install xgboost
收集 xgboost
下载 xgboost-0.4a30.tar.gz (753kB)
100% |################################| 753kB 397kB/s
没有文件/目录
c:userssanderappdatalocaltemppip-build-gqsijfxgbo
ostpip-egg-info(来自 PKG-INFO)
我使用anaconda python安装
我记得在一场 kaggle 比赛中,有人安装 xgboos 失败,
选择了另一种技术,他获得了 2 名...

2016 年 1 月 7 日星期四凌晨 3:31,dsivakumar [email protected]写道:

@phunterlau https://github.com/phunterlau谢谢,这似乎是唯一的
解决方案。


直接回复此邮件或在 GitHub 上查看
https://github.com/dmlc/xgboost/issues/463#issuecomment -169595600。

@Sandy4321 Windows 现在不支持 pip 安装,因为它没有为 VS 命令行编译器设置,如安装指南和故障排除中所述。 请使用windows/中的VS解决方案文件编译安装。 希望它也可以帮助您获得第二名:-)

我正在尝试在没有 Xcode 的 Mac 10.10.5 上安装 Xgboost。 我首先通过 brew install gcc --without-multilib 安装了支持 openmp 的 GCC 5.3。 其次,我通过以下方式构建 xgboost

git clone --recursive https://github.com/dmlc/xgboost
cd xgboost
导出 CC=/usr/local/bin/gcc-5
导出 CXX=/usr/local/bin/g++-5
cp make/config.mk ./config.mk
使-j4

然后出现错误,如下图,
制作: ** [lib/libxgboost.a] 错误 1make: * * 等待未完成的工作....
clangclang: : 警告:警告:编译期间未使用的参数:'-pthread'
编译期间未使用的参数:'-pthread'
ld: 找不到 -lgomp 的库
ld: 找不到 -lgomp 的库
clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
make: ** [lib/libxgboost.so] 错误 1make: * * [xgboost] 错误 1

我忽略了错误并继续前进。 我输入了如下代码
须藤 ./build.sh

然后它说
叮当声:警告:编译期间未使用的参数:'-pthread'
成功搭建单线程xgboost

你能告诉我为什么它仍然是单线程 Xgboost,尽管我已经安装了带有 OpenMP 的 GCC 5。
我应该怎么做才能将我安装的 Xgboost 更改为多线程版本?

最近的 makefile 与 clang-omp 配合得更好。

你好,非常感谢你的解答。
你的意思是现在xgboost不用gcc,而用clang来做编译器也能支持multi threaded,是吗?由于MAC 10.9以上版本自带了clang,所以我是否还需要从homebrew上下载clang-omp
我是新手,之前是根据这个网站上的方法在安装xgboost,现在是否有更新的安装指南,能告诉我具体如何配置吗?
另外,改用clang-omp后,是否要先删除已经安装好的xgboost,然后再重装一次xgboost呢?
谢谢!

At 2016-04-03 01:34:37, "Hongliang Liu" [email protected] wrote:

the recent makefile works better with clang-omp.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub

感谢您的快速回复。 根据您的建议,我已经通过自制软件下载了 clang-omp。
那么,我的下一步是什么? 我是否应该删除当前的 xgboost 并重新安装它。

请将 config.mk 中的默认编译器更改为 clang-omp。 请遵循构建说明 Mac OS X 部分。

谢谢你的指导。 我像这样将 config.mk 中的默认编译器更改为 clang-omp
` 出口 CC = /usr/local/bin/clang-omp

导出 CXX = /usr/local/bin/clang-omp++

ADD_CFLAGS = -fopenmp`

然后我编译
make -j8

但是,错误再次出现:
制作: ** [lib/libxgboost.a] 错误 1make: * * 等待未完成的工作....
clang-3.5clang-3.5: : errorerror: : 没有这样的文件或目录:'rabit/lib/librabit.a'没有这样的文件或目录:'rabit/lib/librabit.a'

make: ** [lib/libxgboost.so] 错误 1make: * * [xgboost] 错误 1

我有什么问题吗?

我跑
sudo ./build.sh
错误出现如下

include/dmlc/omp.h:13:9: 警告:警告:OpenMP 不可用,项目将
编译成单线程代码。 使用支持 OpenMP 的编译器获取
多线程的好处。 [-W#pragma-messages]

pragma message("警告:OpenMP 不可用,"

请尝试通过brew remove clang-omp; brew install clang-omp重新安装clang-omp #$ ; 只需更改config.mk中的这两行(没有ADD_FLAG ),并确保将其复制到与Makefile相同的目录。

export CC = clang-omp
export CXX = clang-omp++

并运行make

使用 Windows 7。来自 yhat Rodeo 的 Anaconda。

尝试安装 xgboost 并收到以下错误。 请帮忙。

`! 点安装 xgboost

收集 xgboost
使用缓存的 xgboost-0.4a30.tar.gz
C:UsersUSERAppDataLocalTemppip-build-dkmqc8n1xgboostpip-egg-info 中没有文件/目录(来自 PKG-INFO)`

@phunterlau 谢谢你的建议。 我尝试了您的指示并收到以下错误。 请给点建议。
我重新安装了clang-imp并在与Makefile相同的目录中的config.mk中更改了两行(没有ADD_FLAG)

export CC = clang-omp
export CXX = clang-omp++

然后我运行sudo make -j4并得到以下错误。

ar crv lib/libxgboost.a 
ar: no archive members specified
usage:  ar -d [-TLsv] archive file ...
    ar -m [-TLsv] archive file ...
    ar -m [-abiTLsv] position archive file ...
    ar -p [-TLsv] archive [file ...]
    ar -q [-cTLsv] archive file ...
    ar -r [-cuTLsv] archive file ...
    ar -r [-abciuTLsv] position archive file ...
    ar -t [-TLsv] archive [file ...]
    ar -x [-ouTLsv] archive [file ...]
make: *** [lib/libxgboost.a] Error 1
make: *** Waiting for unfinished jobs....
clang-3.5: warning: argument unused during compilation: '-pthread'
clang-3.5: warning: argument unused during compilation: '-pthread'

然后我运行sudo ./build.sh并得到以下错误

ar crv lib/libxgboost.a 
ar: no archive members specified
usage:  ar -d [-TLsv] archive file ...
    ar -m [-TLsv] archive file ...
    ar -m [-abiTLsv] position archive file ...
    ar -p [-TLsv] archive [file ...]
    ar -q [-cTLsv] archive file ...
    ar -r [-cuTLsv] archive file ...
    ar -r [-abciuTLsv] position archive file ...
    ar -t [-TLsv] archive [file ...]
    ar -x [-ouTLsv] archive [file ...]
make: *** [lib/libxgboost.a] Error 1
-----------------------------
Building multi-thread xgboost failed

大家好,
要使用 Python 在 Windows 上安装 Xgboost,请按照以下线程中的说明进行操作。

http://stackoverflow.com/questions/33749735/how-to-install-xgboost-package-in-python-windows-platform

@boral是的,当前的 pip 安装不支持窗口平台。 很高兴你知道了

@liyanjin你可以为核心部分做'make xgboost'。 要拥有 ar,您可能需要为 mac 安装 ar

我面临着类似的问题。 我的错误相当

OSError: dlopen(/Users/mlal/anaconda/lib/python2.7/site-packages/libxgboostwrapper.so, 6): Library not loaded: @rpath/./libgomp.1.dylib
  Referenced from: /Users/mlal/anaconda/lib/python2.7/site-packages/libxgboostwrapper.so
  Reason: image not found

我检查了我是否安装了 gcc。
$ 酿造安装 gcc49
警告:homebrew/versions/gcc49-4.9.3 已经安装

我在mac os上我通过anaconda安装了xgboost

@lalmanisha我相信您使用的是 Mac。 Mac 上当前的最佳实践是使用clang-omp而不是gcc 。 您可以尝试从 brew 安装clang-omp并将 config.mk 中的 CC 和 CXX 更改为 clang-omp 吗?

感谢您的回复。 我仍然收到相同的错误消息。 这里是
`------------------------------------------------- -------------------------
OSError Traceback(最后一次调用)
()
14 # 写入当前目录的任何结果都保存为输出。
15
---> 16 将 xgboost 导入为 xgb
17 从 sklearn.linear_model 导入 LogisticRegression
18 将 pandas 导入为 pd

/Users/mlal/anaconda/lib/python2.7/site-packages/xgboost.py 在()
80
81 # 全局加载 XGBoost 库
---> 82 xglib = load_xglib()
83
84

/Users/mlal/anaconda/lib/python2.7/site-packages/xgboost.py 在 load_xglib()
57 如果 len(dll_path) == 0:
58 raise XGBoostLibraryNotFound('cannot find find the files in the candicate path ' + str(dll_path))
---> 59 lib = ctypes.cdll.LoadLibrary(lib_path[0])
60
61 # DMatrix 函数

/Users/mlal/anaconda/lib/python2.7/ctypes/ init .pyc in LoadLibrary(self, name)
441
第442章
--> 443 返回 self._dlltype(name)
444
第445章

/Users/mlal/anaconda/lib/python2.7/ctypes/ init .pyc in init (self, name, mode, handle, use_errno, use_last_error)
363
364 如果句柄为无:
--> 365 self._handle = _dlopen(self._name, mode)
366 其他:
第367章

OSError:dlopen(/Users/mlal/anaconda/lib/python2.7/site-packages/libxgboostwrapper.so,6):未加载库:@rpath/./libgomp.1.dylib
引用自:/Users/mlal/anaconda/lib/python2.7/site-packages/libxgboostwrapper.so
原因:找不到图片
`
我确实更改了 config.mk 文件,如下所示

编译器的选择
出口 CC = clang-omp
出口 CXX = clang-omp
导出 MPICXX = mpicxx

须藤使-j4
ar crv lib/libxgboost.a
ar:未指定存档成员
用法:ar -d [-TLsv] 存档文件...
ar -m [-TLsv] 存档文件...
ar -m [-abiTLsv] 定位存档文件...
ar -p [-TLsv] 存档 [文件 ...]
ar -q [-cTLsv] 存档文件...
ar -r [-cuTLsv] 存档文件...
ar -r [-abciuTLsv] 定位存档文件...
ar -t [-TLsv] 存档 [文件 ...]
ar -x [-outTLsv] 存档 [文件 ...]
制作: ** [lib/libxgboost.a] 错误 1make: * * 等待未完成的工作....
clang:clang:错误:错误:不支持的选项'-fopenmp'不支持的选项'-fopenmp'

make: ** [lib/libxgboost.so] 错误 1make: * * [xgboost] 错误 1
当我跑
须藤 ./build.sh

maker.o build/tree/updater_sync.o dmlc-core/libdmlc.a rabit/lib/librabit_empty.a -pthread -lm
叮当声:警告:编译期间未使用的参数:'-pthread'
成功搭建单线程xgboost
如果你想要多线程版本
请参阅 doc/build.md 中的其他说明

我仍然得到同样的错误
dlopen(/Users/mlal/anaconda/lib/python2.7/site-packages/libxgboostwrapper.so, 6):库未加载:@rpath/./libgomp.1.dylib
引用自:/Users/mlal/anaconda/lib/python2.7/site-packages/libxgboostwrapper.so
原因:找不到图片

好的,我想以上一些帮助和 build.md 的组合帮助我使 xgboost 工作。 谢谢你们 !

@lalmanisha因为您只需要 python 包,所以您只需make xgboost即可删除其他不必要的包,例如需要ar的并行和纱线版本。 它应该成功make 。 很高兴你已经弄清楚了。

尝试在 MAC 上使用git clone安装 Xgboost。 我遵循@LiyanJin的所有指示,直到得到这个答案,我通过自制软件下载了 clang-omp 以使用多线程。

  • 配置.mk:
export CC = clang-omp
export CXX = clang-omp++
export MPICXX = mpicxx
  • 错误 :
clang-omp++ -std=c++0x -Wall -O3 -msse2  -Wno-unknown-pragmas -funroll-loops -Iinclude -fopenmp  -Idmlc-core/include -Irabit/include -fPIC -fopenmp -MM -MT build/learner.o src/learner.cc >build/learner.d
In file included from src/learner.cc:7:
In file included from include/xgboost/logging.h:11:
In file included from dmlc-core/include/dmlc/logging.h:10:
/usr/local/Cellar/clang-omp/2015-04-01/libexec/bin/../include/c++/v1/cstdio:100:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^
1 error generated.
make: *** [build/learner.o] Error 1

pip install效果很好,但我想拥有 python 包中的最新功能。

一些技巧 ?


编辑:找到解决方案。 只是xcode-select --installmake 。 希望它会帮助其他人。

@armgilles是的:默认情况下,mac 没有安装带有头文件的编译器,而clang-omp需要本地安装的 Xcode,通过xcode-select --install安装它升级到新系统后的所有内容都可以解决问题.

我不得不从头开始构建它:

git clone --recursive https://github.com/dmlc/xgboost.git  
cd xgboost  
./build.sh
pip install -e python-package  

hnykda 建议在 Ubuntu 16.0.4 上对我有用

@phunterlau
我得到了同样的错误。
ar crv lib/libxgboost.a
ar:未指定存档成员
用法:ar -d [-TLsv] 存档文件...
ar -m [-TLsv] 存档文件...
ar -m [-abiTLsv] 定位存档文件...
ar -p [-TLsv] 存档 [文件 ...]
ar -q [-cTLsv] 存档文件...
ar -r [-cuTLsv] 存档文件...
ar -r [-abciuTLsv] 定位存档文件...
ar -t [-TLsv] 存档 [文件 ...]
ar -x [-outTLsv] 存档 [文件 ...]
制作: * [lib/libxgboost.a] 错误 1

我已经安装了ar。 我想知道“ar crv”做什么,如果我可以使用其他命令来替换。
你已经提到“ @liyanjin你可以为核心部分做'make xgboost'。拥有ar,你可能需要为mac安装ar”,我不明白“为核心部分做'make xgboost'”方法。 希望得到您的建议

我已通过以下方式在我的 MAC (macOS 10.12.3) 上成功安装了该软件包:

brew install --with-clang llvm
brew install cmake
brew install gcc --without-multilib

git clone --recursive https://github.com/dmlc/xgboost
cd xgboost; cp make/config.mk ./config.mk; make -j4

cd python-package/ ; python setup.py install

@hnykda很多时候,可行的解决方案是看似简单的解决方案。 谢啦。

我发现对我有用的解决方案是导航到
/home/用户名/anaconda3/lib/python3.5/site-packages/xgboost
并运行 ./build-python.sh

安装xgboost时似乎有很多问题。 我试图安装到 Mac 上,也失败了。 osmeone 能告诉我最终的解决方案是什么吗?

对我有用的是在 linux 上添加以下内容......信用(上面的每个人)

git clone --recursive https://github.com/dmlc/xgboost.git  
cd xgboost  
./build.sh
pip install -e python-package 
cd python-package
python setup.py install

对我来说,在 MacOS Sierra 上工作后:
brew install gcc --without-multilib

执行此命令:

export CC=gcc-7
export CXX=g++-7

@philipshurpik 非常感谢!

@philipshurpik这对我来说非常有用,谢谢!

此页面是否有帮助?
0 / 5 - 0 等级