xgboost: Python predict() does not work with multiprocessing

Related:

It has been reported that the predict() function in the Python interface does not work well with multiprocessing. We should find a way to allow multiple processes to predict with the same model simultaneously.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Is there any update on this. It seems that this is complete stoper from using xgb on Production…?

Thanks for reminding. Let’s see if I can get to this at the weekend.

A quick update on this, thread safe prediction/inplace-prediction are now supported.

Hi, the inplace predict is an alternative to using multi-process. The hang is caused by fork safety issue in libgomp in gcc, which we cannot fix. Please take a look at https://github.com/dmlc/xgboost/issues/7044#issuecomment-1039912899 for a potential workaround and more background.

On 11/20/22 21:48, Evan Sangaline wrote:

You can now use |inplace_predict()| for thread-safe prediction.

@trivialfis https://github.com/trivialfis @hcho3 https://github.com/hcho3 I’m still experiencing this issue with the latest v1.7.1 release and |model.inplace_predict()|. When loading a pickled model before forking, any call to |XGBClassifier.predict()| after forking will hang. The predictor is set to |auto| on a machine with no GPU or CUDA installed, and |model._can_use_inplace_predict()| returns |True|. The hang occurs here https://github.com/dmlc/xgboost/blob/v1.7.1/python-package/xgboost/sklearn.py#L1140-L1147:

predts = self.get_booster().inplace_predict( data=X, iteration_range=iteration_range, predict_type=“margin” if output_margin else “value”, missing=self.missing, base_margin=base_margin, validate_features=validate_features, )

— Reply to this email directly, view it on GitHub https://github.com/dmlc/xgboost/issues/4246#issuecomment-1321137550, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7YPKKYT6JKX3C5NYXOC4TWJIT2BANCNFSM4G5FTZSQ. You are receiving this because you were mentioned.Message ID: @.***>