【问题标题】:No speedup using XGBClassifier with GPU support使用支持 GPU 的 XGBClassifier 没有加速
【发布时间】:2018-12-20 16:56:58
【问题描述】:

在以下代码中,我尝试搜索 xgboost 的不同超参数。

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 |
+-----------------------------------------------------------------------------+

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

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

可能的原因是什么?

【问题讨论】:

  • 您确定 CUDA 工具包和 gpu xgboost 安装正确吗?也可以尝试使用 'tree_method':'gpu_hist' 而不将其包装在 kvargs {} 中。与所有其他参数相同。
  • @VivekKumar 是的,我想是的。关于'tree_method'参数,我认为它没有定义为普通参数,我们应该将它包含在kvargs中。
  • 你有什么解决办法吗?问题对我来说是真实的。
  • @QtRoS 看看这个链接:github.com/dmlc/xgboost/issues/2819

标签: gpu xgboost


【解决方案1】:

我想修改两点。 Ubuntu下xgboost的安装,

制作-j4

至于 Vivek 的意见,我希望您检查 'tree_method' 参数是否符合以下要求。

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

【讨论】:

    【解决方案2】:

    尝试添加单个参数:updater='grow_gpu'

    【讨论】:

      【解决方案3】:

      我知道它有点晚了,但是,如果 cuda 的安装正确完成,下面的代码应该可以工作:

      没有网格搜索:

      import xgboost
      
      xgb = xgboost.XGBClassifier(n_estimators=200, tree_method='gpu_hist', predictor='gpu_predictor')
      xgb.fit(X_train, y_train)
      

      使用 GridSearch:

      params = {
              'max_depth': [3,4,5,6,7,8,10],
              'learning_rate':[0.001, 0.003, 0.01,0.03, 0.1,0.3],
              'n_estimators':[50,100,200,300,500,1000],
              .... whatever ....
      }
      xgb = xgboost.XGBClassifier(tree_method='gpu_hist', predictor='gpu_predictor')
      tuner = GridSearchCV(xgb, params=params)
      tuner.fit(X_train, y_train)
      
      # OR you can pass them in params also.
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-05-05
        • 2015-10-04
        • 2020-12-08
        • 1970-01-01
        • 2019-09-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多