GPU加速xgboost——win10下配置

xgboost是一个非常好的模型工具,但是当遇到数据量比较大的时候迭代的速度会很慢(博主打比赛的时候简直想砸电脑啊),因此就找了点资料配置了GPU加速。

这里面遇到很多坑。

1.使用官网的配置方案

反正这个我从来没成功了,试了n次。我这里就不写了,贴出来链接:

http://xgboost.readthedocs.io/en/latest/build.html#building-with-gpu-support


2.使用知乎大佬的方法

先用cmake生成文件,然后用vs编译,我同样没成功。贴出来链接:

https://zhuanlan.zhihu.com/p/29904369


3.使用别人编译好的xgboost,我这个成功了。

3.1第一步安装vs,我装的是vs14-2015,如果你想装这个版本的话,请确保你把之前的版本卸载干净再装,不然可能出现未知错误,那么坑就多了。

可以从这里找到vs的对应下载链接:https://msdn.itellyou.cn/

3.2安装配置cuda,这个我装的是cuda8,直接到官网下然后安装就可以了,具体可以参考我的另外一篇博文http://blog.csdn.net/voidfaceless/article/details/53711550

3.3下载别人配置好的xgboost

国外有个好心人把配置好的xgboost上传了,几乎每天的版本都会有,链接:http://ssl.picnet.com.au/xgboost/。左边是cpu版,右边是支持gpu加速版。点击需要的版本下载xgboost.dll就可以了

3.3安装xgboost

由于是别人配置好的,安装起来特别简单了。首先下载xgboost源码(其实这里我们不需要用git clone --recursive,因为用的是编译好的dll,因此不需要下载那么完整,只需要python-package完整即可)

git clone --recursive https://github.com/dmlc/xgboost

之后将下载的xgboost.dll库文件放入到master\python-package\xgboost目录,进入master\python-package目录,执行以下命令行

python setup.py install

3.4尽情地享受gpu加速吧

另外,官方提供了一个基准(Benchmarks)

Training time time on 1,000,000 rows x 50 columns with 500 boosting iterations and 0.25/0.75 test/train split on i7-6700K CPU @ 4.00GHz and Pascal Titan X.

i7-6700K的CPU(4.00GHz)和Pascal Titan X,数据集大小为 1,000,000行 x 50列,按0.25/0.75划分测试集和训练集,训练时间如下


tests\benchmark目录下
分别执行

python benchmark.py --tree_method gpu_hist
python benchmark.py --tree_method hist
python benchmark.py --tree_method gpu_exact
python benchmark.py --tree_method exact
我只执行了上面两个,分别是45秒和147秒.

猜你喜欢

转载自blog.csdn.net/voidfaceless/article/details/78338678