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

标签 python gpu xgboost

我一直在尝试在 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/

相关文章:

opengl - 使用 CentOS 在 AWS GPU 实例上运行 OpenGL

python-3.x - XGBRegressor : change random_state no effect

python - 使用 CountVectorizer 在 python 中 todense 时出现内存错误

python - 具有多个类别的图像分类器

python - Azure Devops 上传图像

opengl-es - GLSL 和 GPU 片段着色器执行中的总面积表

c++ - 为什么我得到 Present table dump for device[1] : NVIDIA Tesla GPU 0 in this code?

python - distutils索引错误: tuple index out of range

python - 如何使用 any() 来测试两个数组是否重叠

python - 无法打开 pickle 的 Sagemaker XGBoost 模型