XGBoost training on gpu using dataframe structures - Stack Overflow

I'm getting the error below, I think because my X_train and y_train values are relative to being a

I'm getting the error below, I think because my X_train and y_train values are relative to being a dataframe on my cpu.

''Falling back to prediction using DMatrix due to mismatched devices. This might lead to higher memory usage and slower performance. XGBoost is running on: cuda:0, while the input data is on: cpu. Potential solutions:''

I'm running a gridsearch currently which is via sckitlearn's api - which does not allow for the usage of non numpy/dataframe inputs. How can I continue to train on my GPU for a gridserach?

I'm getting the error below, I think because my X_train and y_train values are relative to being a dataframe on my cpu.

''Falling back to prediction using DMatrix due to mismatched devices. This might lead to higher memory usage and slower performance. XGBoost is running on: cuda:0, while the input data is on: cpu. Potential solutions:''

I'm running a gridsearch currently which is via sckitlearn's api - which does not allow for the usage of non numpy/dataframe inputs. How can I continue to train on my GPU for a gridserach?

Share Improve this question asked Mar 12 at 3:29 user54565user54565 232 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I believe that the problem you're facing is also referenced here. trivialfis provided some demo code in his reply, which I shall paste down here.

import cupy as cp
import xgboost as xgb
from sklearn.datasets import make_regression

X, y = make_regression()

reg = xgb.XGBRegressor()
reg.fit(X, y)

# No warning, reg and X are on CPU
reg.predict(X)

# Put X into GPU
X = cp.array(X)
# Put reg to GPU
reg.set_params(device="cuda")
# No warning, both on GPU
reg.predict(X)

# Warning, reg is on CPU, but X on GPU
reg.set_params(device="cpu")
reg.predict(X)

X = cp.asnumpy(X)
reg.set_params(device="cuda")
# Warning, reg is on GPU, but X on CPU
reg.predict(X)

anonymousTechpreneur also provided his code in the Github issue and has just the code you need, I however think you should try it for yourself.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744770755a4592744.html

相关推荐

  • XGBoost training on gpu using dataframe structures - Stack Overflow

    I'm getting the error below, I think because my X_train and y_train values are relative to being a

    16小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信