XGBoost with GPU support installation error: can&#

2020-05-09 22:39发布

问题:

Similar non-duplicate posts:

  • How to install xgboost package in python (windows platform)?
  • XGBoost installation issues for Python Anaconda Windows 10 (18 May 2018)

I looked around through multiple Stack Overflow posts about installing xgboost for Python on Windows 10, but none of them mentioned the issue I was having. In addition, all the posts seem to be about installing xgboost without GPU support.

I also found the official installation guide to be quite difficult to follow, as it omits certain directory changes and has some different options that disrupt the flow of commands. Below are the steps I used to install xgboost with GPU support on Windows 10 with Python 3.6.4:

Necessary software

The first step is to install the following software that will be required for this installation:

  • CMake, adding CMake to your system PATH
  • Visual Studio 2015 with Update 3 and Visual C++
  • Git for Windows, making sure to add it to the PATH variable
  • CUDA Note: the version must be at least 8.0. I used 9.0 because of compatibility issues with the newer versions and Tensorflow

Ensure the following packages are installed:

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

Step 1: Cloning the repo

Run the following in the VS2015 x64 Native Tools Command Prompt that comes installed with VS2015 in administrator mode, in the folder you want the xgboost folder to be located in:

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

Step 2: Making the .sln file with CMake

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

Step 3: Installing the Python Package

If the above complete without any errors, run the following:

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

Error:

At this point, I get the following error and the installation fails:

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

See my answer below for my solution, and please post another answer if you find a better way to solve this problem.

回答1:

Edit xgboost/python-package/setup.py and change line 38 to the following (source) :

include_package_data=False

Now it should install without any problems. To see that it's all working fine, just run the following command, and if it runs without errors it's good to go:

python -c "import xgboost"

You can run additional tests after installation using the nose package with the following command executed from the root xgboost/ directory:

nosetests tests/python

To further confirm that it installed with GPU support, you can use the benchmarking scripts that come included with the installation:

gpu_hist algorithm:

python tests/benchmark/benchmark_tree.py

Output:

Train Time: 46.25219774246216 seconds

hist algorithm without GPU:

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

Output:

Train Time: 84.04853415489197 seconds