Windows10下安装GPU版XGBoost报错:无法复制xgboost\lib
Hey there, I’ve fought through the exact same frustrating error while installing GPU-enabled XGBoost on Windows 10 with Python 3.6.4—let me break down what’s going wrong and how to fix it.
Why That "can't copy 'xgboost\lib'" Error Happens
The root issue is that after your CMake build finishes, the compiled xgboost.dll library ends up in the build/Release folder, but the Python setup script expects it to live in a xgboost/lib directory (which doesn’t get created automatically with your current steps).
Quick Fix: Manually Move the Library File
If you want a fast solution without changing your original workflow:
- Navigate back to your main xgboost root folder, then create the missing
libdirectory inside the nestedxgboostfolder:mkdir xgboost/lib - Go to the
build/Releasefolder, copy thexgboost.dllfile, and paste it into the newxgboost/libdirectory you just made. - Head back to the
python-packagefolder and re-run the install command:python setup.py install
This should resolve the copy error immediately.
Better Long-Term Fix: Tweak CMake to Output to the Right Path
To avoid manual file copying entirely, adjust your CMake command to send the compiled library straight to the path the setup script expects:
- When running your initial CMake command, add an extra flag to set the release output directory:
cmake .. -G "Visual Studio 14 2015 Win64" -DUSE_CUDA=ON -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=../xgboost/lib - Proceed with the build as before:
cmake --build . --target xgboost --config Release - Now the
xgboost.dllwill be automatically placed inxgboost/lib, so runningpython setup.py installin thepython-packagefolder will work without any missing file errors.
Extra Tips to Avoid Headaches
- Always run the VS2015 x64 Native Tools Command Prompt as Administrator: Permission issues can sometimes prevent CMake from generating files in the correct locations.
- Double-check that CUDA 9.0 is properly added to your system PATH, and that Visual Studio 2015 has the full Visual C++ components installed (the default install sometimes skips these—go to Programs and Features > Modify Visual Studio 2015 to verify).
- If you hit weird build errors, clean your build directory and start fresh:
Then re-run the CMake and build commands from scratch.cd build rmdir /s /q *
内容的提问来源于stack exchange,提问作者Mihai Chelaru

