ubuntu 18 安装xgboost GPU版本

综合上述两个帖子:

https://www.cnblogs.com/huadongw/p/6161145.html

https://blog.csdn.net/u011587516/article/details/78995186

先把之前安装的xgboost都卸载干净:

pip uninstall xgboost

确保电脑里安装了cuda。

然后按照下面的步骤来安装GPU版本的xgboost:

$git clone --recursive https://github.com/dmlc/xgboost
$cd xgboost
$mkdir build
$cd build
$cmake .. -DUSE_CUDA=ON
$make -j
$sh build.sh
$cd python-package
$python setup.py install
 
测试GPU
testsenchmark目录下

分别执行

python benchmark.py --tree_method gpu_hist
python benchmark.py --tree_method hist
可以看到,第一个gpu版本的比第二个非GPU版本的快。在实际的代码中,只要在添加下面的参数就行了
param['tree_method'] = 'gpu_hist'

 
原文地址:https://www.cnblogs.com/zhoubiyu/p/10425759.html