XGBoost with GPU support installation error: can't copy 'xgboost\lib': doesn't exist or not a regular file

XGBoost with GPU support installation error: can't copy 'xgboost\lib': doesn't exist or not a regular file

相似非重复posts:

我查看了多个 Stack Overflow post 关于在 Windows 10 上为 Python 安装 xgboost,但其中 none 提到了这个问题我有。此外,所有 post 似乎都是关于在没有 GPU 支持的情况下安装 xgboost

我还发现 official installation guide 很难理解,因为它省略了某些目录更改并且有一些不同的选项会中断命令流。以下是我在 Windows 10 和 Python 3.6.4:

上安装具有 GPU 支持的 xgboost 的步骤

必备软件

第一步是安装本次安装所需的以下软件:

确保安装了以下软件包:

conda install -y numpy scipy pandas matplotlib nose scikit-learn graphviz python-graphviz

第 1 步:克隆存储库

运行 在管理员模式下随 VS2015 安装的 VS2015 x64 本机工具命令提示符中的以下内容,在您希望 xgboost 文件夹所在的文件夹中:

git clone --recursive https://github.com/dmlc/xgboost
cd xgboost
git submodule init
git submodule update

第 2 步:使用 CMake 制作 .sln 文件

mkdir build
cd build
cmake .. -G "Visual Studio 14 2015 Win64" -DUSE_CUDA=ON
cmake --build . --target xgboost --config Release

第 3 步:安装 Python 包

如果以上完成没有任何错误,运行以下:

cd ../python-package
python setup.py install

错误:

此时出现如下错误,安装失败:

error: can't copy 'xgboost\lib': doesn't exist or not a regular file

请参阅下面的答案以了解我的解决方案,如果您找到解决此问题的更好方法,请post另一个答案。

编辑 xgboost/python-package/setup.py 并将第 38 行更改为以下内容 (source) :

include_package_data=False

现在安装应该没有任何问题。要查看它是否一切正常,只需 运行 以下命令,如果它 运行 没有错误,那就很好了:

python -c "import xgboost"

您可以 运行 安装后使用 nose 包进行额外测试,并从 xgboost/ 根目录执行以下命令:

nosetests tests/python

要进一步确认它安装了 GPU 支持,您可以使用安装附带的 benchmarking scripts

gpu_hist算法:

python tests/benchmark/benchmark_tree.py

输出:

Train Time: 46.25219774246216 seconds

没有 GPU 的 hist 算法:

python tests/benchmark/benchmark_tree.py --tree_method hist

输出:

Train Time: 84.04853415489197 seconds