LoginSignup
5

More than 3 years have passed since last update.

GPUが使えるXGBoostをWin10にインストールする

Posted at

環境

以下の2つの環境で成功済み

  • 1
    • Windows 10 Pro 1809
    • CUDA Toolkit 10.1 update 1
    • Visual Studio Community 2019
  • 2
    • Windows 10 Home 1903
    • CUDA Toolkit 10.1 update 2
    • Visual Studio Community 2019

事前に入れるもの

Visual Studioでコンパイルする場合

XGBoostのインストール

git bashで以下のコマンドを実行する

git clone --recursive https://github.com/dmlc/xgboost
cd xgboost
mkdir build
cd build
cmake .. -G"Visual Studio 16 2019" -DUSE_CUDA=ON

("Visual Studio 16 2019"は手元のVisual Studioのバージョンに合わせる)

GPUを使わない場合は最後の行の-DUSE_CUDA=ONをつけないでおく:

cmake .. -G"Visual Studio 16 2019"

Python libraryのインストール

以上のコマンドでbuildディレクトリにコンパイルされるので

今度はxgboostディレクトリでpowershellを開いて

cd python-package
python setup.py install

を実行すればよい。

XGBoostLibraryNotFound

ここで

Traceback (most recent call last):
  File "setup.py", line 22, in <module>
    for libfile in libpath['find_lib_path']():
  File "xgboost/libpath.py", line 50, in find_lib_path
    'List of candidates:\n' + ('\n'.join(dll_path)))
XGBoostLibraryNotFound: Cannot find XGBoost Library in the candidate path, did you install compilers and run build.sh in root path?

と言われるときは

pip install xgboost

をしてから再度python setup.py installするとうまくいく場合がある。

確認

Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information. 
>>> import xgboost
>>> xgboost
<module 'xgboost' from 'C:\\Users\\username\\Documents\\xgboost\\python-package\\xgboost\\__init__.py'> 

上の例だとxgboostのフォルダをDocumentsに置いており、そこから読み込まれていることがわかる

参考

Installation Guide — xgboost 1.0.0-SNAPSHOT documentation

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5