没有使用GPU支持XGBClassifier加速

问题描述:

在下面的代码中,我尝试搜索xgboost的不同超参数。没有使用GPU支持XGBClassifier加速

param_test1 = { 
'max_depth':list(range(3,10,2)), 
'min_child_weight':list(range(1,6,2)) 
} 
predictors = [x for x in train_data.columns if x not in ['target', 'id']] 
gsearch1 = GridSearchCV(estimator=XGBClassifier(learning_rate =0.1, n_estimators=100, max_depth=5, 
               min_child_weight=1, gamma=0, subsample=0.8, colsample_bytree=0.8, 
               objective= 'binary:logistic', n_jobs=4, scale_pos_weight=1, seed=27, 
               kvargs={'tree_method':'gpu_hist'}), 
        param_grid=param_test1, scoring='roc_auc', n_jobs=4, iid=False, cv=5, verbose=2) 
gsearch1.fit(train_data[predictors], train_data['target']) 

即使我使用kvargs={tree_method':'gpu_hist'},我在实现中没有加速。按照nvidia-smi,该GPU并不多参与计算:

+-----------------------------------------------------------------------------+ 
| NVIDIA-SMI 375.66     Driver Version: 375.66     | 
|-------------------------------+----------------------+----------------------+ 
| GPU Name  Persistence-M| Bus-Id  Disp.A | Volatile Uncorr. ECC | 
| Fan Temp Perf Pwr:Usage/Cap|   Memory-Usage | GPU-Util Compute M. | 
|===============================+======================+======================| 
| 0 GeForce GTX 1080 Off | 0000:01:00.0  On |     N/A | 
| 0% 39C P8 10W/200W | 338MiB/8112MiB |  1%  Default | 
+-------------------------------+----------------------+----------------------+ 

+-----------------------------------------------------------------------------+ 
| Processes:              GPU Memory | 
| GPU  PID Type Process name        Usage  | 
|=============================================================================| 
| 0  961 G /usr/lib/xorg/Xorg        210MiB | 
| 0  1675 G compiz           124MiB | 
| 0  2359 G /usr/lib/firefox/firefox       2MiB | 
+-----------------------------------------------------------------------------+ 

我已经安装了支持xgboost在Ubuntu使用以下命令的GPU:

$ git clone --recursive https://github.com/dmlc/xgboost 
$ mkdir build 
$ cd build 
$ cmake .. -DUSE_CUDA=ON 
$ make -j 

什么是可能的原因是什么?

+0

您确定CUDA toolkit和gpu xgboost安装正确吗?也可以尝试使用'tree_method':'gpu_hist',而不将其包装在'kvargs {}'中。与其他所有参数相同。 –

+0

@VivekKumar是的,我认为是。关于'tree_method'参数,我认为它没有被定义为正常参数,我们应该把它包含在kvargs中。 – Hossein

+0

你有什么解决方案吗?问题对我来说是实际的。 – QtRoS

我想修改两件事情。 xgboost的在Ubuntu的安装,

使-j4

至于维韦克的意见,我想你检查“tree_method”参数枝条对于以下。

http://xgboost.readthedocs.io/en/latest/parameter.html