Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
166 views
in Technique[技术] by (71.8m points)

python - Error when loading XGBoost model and using predict

I am receiving the following error when I try to load an XGBoost model and use predict:

XGBoostError: [11:42:10] ../src/data/iterative_device_dmatrix.h:50: Not implemented.
Stack trace:
  [bt] (0) /usr/local/lib/python3.6/dist-packages/xgboost/lib/libxgboost.so(+0x8d264) [0x7f5c35a28264]
  [bt] (1) /usr/local/lib/python3.6/dist-packages/xgboost/lib/libxgboost.so(+0x37817f) [0x7f5c35d1317f]
  [bt] (2) /usr/local/lib/python3.6/dist-packages/xgboost/lib/libxgboost.so(+0x21b620) [0x7f5c35bb6620]
  [bt] (3) /usr/local/lib/python3.6/dist-packages/xgboost/lib/libxgboost.so(+0x21d154) [0x7f5c35bb8154]
  [bt] (4) /usr/local/lib/python3.6/dist-packages/xgboost/lib/libxgboost.so(+0x17255b) [0x7f5c35b0d55b]
  [bt] (5) /usr/local/lib/python3.6/dist-packages/xgboost/lib/libxgboost.so(+0x1a2655) [0x7f5c35b3d655]
  [bt] (6) /usr/local/lib/python3.6/dist-packages/xgboost/lib/libxgboost.so(XGBoosterPredict+0xd5) [0x7f5c35a1bb55]
  [bt] (7) /usr/lib/x86_64-linux-gnu/libffi.so.6(ffi_call_unix64+0x4c) [0x7f5ce25c5dae]
  [bt] (8) /usr/lib/x86_64-linux-gnu/libffi.so.6(ffi_call+0x22f) [0x7f5ce25c571f]

If I were to train the model and leave it in RAM, so I didn't need to load it, I don't get the error.

Here is the code I am using:

reg.save_model('/content/drive/MyDrive/Share/XGB_Final/reg1.model')
reg2 = xgb.Booster(model_file='/content/drive/MyDrive/Share/XGB_Final/reg1.model')

x = xgb.DeviceQuantileDMatrix(cp.array(data[:,1:],dtype='float32'))
yPred = reg2.predict(xDay,ntree_limit=2000)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I needed to set the predictor parameter to gpu_predictor after I loaded the model from disk, since CPU_predictor is default and I am using a DeviceQuantileMatrix.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...