Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use GPU while training XGBoost model?

I have been trying to train a XGBoost model in a Jupyter Notebook. I installed XGboost(GPU) by following commands:

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

But whenever I try to train the model but model.fit, the kernel restarts after a few minutes. code:

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)

where X_train and y_train are derived form sklearn TfidfVectorizer

I have cuda installed, cat /usr/local/cuda/version.txt gives : CUDA Version 10.2.89

like image 983
flames Avatar asked Jul 01 '26 07:07

flames


1 Answers

Try using param['updater'] = 'grow_gpu' as another parameter with XGBClassifier. Read this in detail here: https://xgboost.ai/2016/12/14/GPU-accelerated-xgboost.html.

like image 63
Sudhakar Samak Avatar answered Jul 02 '26 21:07

Sudhakar Samak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!