Installing XGBoost on Windows using Visual Studio 2017
Some of the guides I came across were outdated or a little complicated. This takes you through installing XGBoost with Anaconda in Windows using Visual Studio 2017
Tools Installation
- Install Anaconda for Windows https://www.anaconda.com/download/
- Install latest version of CMake for Windows 64bit. I chose option to add to PATH https://cmake.org/download/
- Install Git for Windows. I chose option to add to PATH https://git-scm.com/downloads
- Install Visual Studio 2017 community edition https://www.visualstudio.com/downloads/
Note, when installing VS2017, make sure you choose the option to install the C++ development tools. If you already have VS2017 installed, you can add this from the Tools > Get Tools and Features option. Either way, you’ll get this screen and will want to check this box for “Desktop development with C++”
Building XGBoost
First you’ll want to clone the repo along with all of its submodules
git clone --recursive https://github.com/dmlc/xgboost
Open up the Windows command prompt and type
cd c:\path_to_xgboost_repo
mkdir build
cd build
cmake .. -G "Visual Studio 15 2017 Win64"
This will create a bunch of files in the /build directory. Open up the .sln file using Visual Studio 2017 and run:
- Build > Clean Solution
- Build > Build Solution
You will now have a file called libxgboost.dll under c:\your_path_to_repo\lib folder. Copy this DLL to c:\your_path_to_repo\python_package
Installing XGBoost
Open Anaconda Prompt and run the following commands to create a new environment for XGBoost
conda create -n xgboost
activate xgboost
install numpy scipy pandas scikit-learn jupyter nb_conda
python c:\your_path_to_repo\python-package\setup.py install
This installs some required & common packages along with the XGBoost package. I like the nb_conda package because it is an extension of Jupyter that lets you toggle environments from within the Jupyter interface
Testing XGBoost
You should be up and running. If you can run the following command, you should be set
import xgboost as xgb