训练XGBoost模型时如何使用GPU?

fla*_*mes 7 python gpu xgboost

我一直在尝试在 Jupyter Notebook 中训练 XGBoost 模型。我通过以下命令安装了 XGboost(GPU):

\n\n
git clone \xe2\x80\x94 recursive https://github.com/dmlc/xgboost\ncd xgboost\nmkdir build\ncd build\ncmake .. -DUSE_CUDA=ON\nmake -j\n
Run Code Online (Sandbox Code Playgroud)\n\n

但每当我尝试训练模型时model.fit,内核都会在几分钟后重新启动。\n代码:

\n\n
params = { 'max_depth': 50, 'n_estimators':80, 'learning_rate':0.1, 'colsample_bytree':7, 'gamma':0, 'reg_alpha':4, 'objective':'binary:logistic', 'eta':0.3, 'silent':1, 'subsample':0.8, 'tree_method':'gpu_hist', 'predictor':'gpu_predictor',}\nxgb_model = xgb.XGBClassifier(**params).fit(X_train, y_train) \nxgb_prediction = xgb_model.predict(X_valid)\n
Run Code Online (Sandbox Code Playgroud)\n\n

其中 X_train 和 y_train 源自 sklearnTfidfVectorizer

\n\n

我已经安装了 cuda,\ncat /usr/local/cuda/version.txt给出:CUDA Version 10.2.89

\n

Sud*_*mak 4

尝试将其用作param['updater'] = 'grow_gpu'XGBClassifier 的另一个参数。在这里详细阅读:https ://xgboost.ai/2016/12/14/GPU-accelerated-xgboost.html 。

  • 使用tree_method =“gpu_hist” (2认同)