xgboost
xgboost copied to clipboard
python with GPU, it slows down 5~6x
ENVIRONMENT :
WIndows10, Anaconda3, Python 3.6 Laptop with Nvidia geforce 940mx(not pascal architecture, it's maxwell architecture) and i7 7500U CPU. RAM 16gb. Installed xgboost gpu support version.
Problem :
- with cpu : 37 tasks takes around 10 seconds.
- with gpu : 37 tasks takes more than 1 minute.
Code :
1. with cpu
xgb_model = xgb.XGBClassifier()
parameters = {
'objective' : ['binary:logistic'],
'nthread' : [8],
'n_estimators' : [700],
'learning_rate' : [0.005, 0.01, 0.025],
'gamma' : [0.05, 0.1, 0.3],
'max_depth' : [3, 5, 7, 9],
'min_child_weight' : [3, 5, 7],
'subsample' : [0.3, 0.5, 0.7],
'colsample_bytree' : [0.3, 0.5, 0.7]
}
clf = GridSearchCV(xgb_model, parameters, n_jobs=2, cv=5, verbose=2, scoring='precision')
clf.fit(data[predictors], data['y'])
2. with gpu
xgb_model = xgb.XGBClassifier(tree_method='gpu_hist')
parameters = {
'objective' : ['gpu:binary:logistic'],
'nthread' : [8],
'n_estimators' : [700],
'learning_rate' : [0.005, 0.01, 0.025],
'gamma' : [0.05, 0.1, 0.3],
'max_depth' : [3, 5, 7, 9],
'min_child_weight' : [3, 5, 7],
'subsample' : [0.3, 0.5, 0.7],
'colsample_bytree' : [0.3, 0.5, 0.7]
}
clf = GridSearchCV(xgb_model, parameters, n_jobs=2, cv=5, verbose=2, scoring='precision')
clf.fit(data[predictors], data['y'])
I know that my GPU is not good and maxwell architecture so I've changed tree method to 'gpu_exact'(accordring to document), but the result was similar.
Always 6X slower than CPU and GPU usage is under 20%. What I have to do?
general questions are now encouraged at https://discuss.xgboost.ai/