我一直在尝试在 Jupyter Notebook 中训练 XGBoost 模型。我通过以下命令安装了 XGboost(GPU):
git clone — recursive https://github.com/dmlc/xgboost
cd xgboost
mkdir build
cd build
cmake .. -DUSE_CUDA=ON
make -j
但是每当我尝试训练模型时,
model.fit
,内核会在几分钟后重新启动。代码:
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',}
xgb_model = xgb.XGBClassifier(**params).fit(X_train, y_train)
xgb_prediction = xgb_model.predict(X_valid)
其中 X_train 和 y_train 派生自 sklearn
TfidfVectorizer
我安装了cuda,
cat /usr/local/cuda/version.txt
给:CUDA Version 10.2.89
最佳答案
尝试使用 param['updater'] = 'grow_gpu'
作为 XGBClassifier 的另一个参数。在此处详细阅读:https://xgboost.ai/2016/12/14/GPU-accelerated-xgboost.html .
关于python - 如何在训练 XGBoost 模型时使用 GPU?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59878070/