Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the function "LGBM_BoosterPredictForMat" thread safe? #666

Closed
zhxwmessi opened this issue Jun 30, 2017 · 6 comments
Closed

Is the function "LGBM_BoosterPredictForMat" thread safe? #666

zhxwmessi opened this issue Jun 30, 2017 · 6 comments

Comments

@zhxwmessi
Copy link

Is the function "LGBM_BoosterPredictForMat" in c_api thread safe ? If I call this function to predict with multi thread. Since Xgboost predict function is not thread safe

@guolinke
Copy link
Collaborator

guolinke commented Jun 30, 2017

@zhxwmessi

  1. The prediction is already multi-threading.
  2. If using the different model, it is thread-safe.
  3. if using the same model but with the same number of iterations, it is thread-safe.

updated:

it is always thread-safe since we use a lock here: https://github.com/Microsoft/LightGBM/blob/master/src/c_api.cpp#L168

@ameyais
Copy link

ameyais commented Jan 9, 2018

@guolinke

  1. The prediction is already multi-threading.
  2. If using the different model, it is thread-safe.
  3. if using the same model but with the same number of iterations, it is thread-safe.

I want to remove the lock, because I want to use predict with multi thread to speed up
If I remove the lock, is it still thread safe under situation 3?

@l616q
Copy link

l616q commented Sep 18, 2018

@guolinke

  1. The prediction is already multi-threading.
  2. If using the different model, it is thread-safe.
  3. if using the same model but with the same number of iterations, it is thread-safe.

I want to remove the lock, because I want to use predict with multi thread to speed up
If I remove the lock, is it still thread safe under situation 3?

hi, have you remove lock and can get the right predict result?

@guolinke
Copy link
Collaborator

@ameyais it is thread-safe.

@l616q
Copy link

l616q commented Sep 18, 2018

@guolinke Is there a possible way to rewrite the predict function to make the prediction more faster?except delete this lock.

@guolinke
Copy link
Collaborator

@l616q refer to https://github.com/dmlc/treelite
LightGBM is designed for the training.

@lock lock bot locked as resolved and limited conversation to collaborators Mar 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants