-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
GridSearchCV with xgboost estimator hangs when n_jobs!=1 #6627
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
Comments
This is very likely a completely different issue indeed. Could you post the full code that you are using ? It looks like the Santander dataset from Kaggle is not that big so we could download it and see whether we can reproduce the problem. I am assuming this is the dataset you are talking about: https://www.kaggle.com/c/santander-customer-satisfaction/data. |
Yes, that is the dataset. So:
As I mentioned I am using scikit-learn version is 0.18.dev0, don't know if this works with previous versions. |
Great thanks ! General comment: the easier you make it to reproduce your problem the better the quality of feedback you'll get. Minor comment you can use python after the triple backquotes to have syntax highlighting in your snippet, see this link. |
OK I am guessing you are using xgboost and there may be a bad interaction going on between the xgboost thread pool and multiprocessing from the python stdlib. You can find a bit more details there: https://pythonhosted.org/joblib/parallel.html#bad-interaction-of-multiprocessing-and-third-party-libraries A few things you could try to see whether the issue goes away:
|
Thank you lesteve, I removed n_jobs from the GridSearchCV call and that fixed the issue. I might try what you suggest in the future but for now I am happy as it is. I just wanted to make you aware of this issue, and possibly help others who may encounter the same problem, suggesting a possible temporary solution. Thank you. |
Would you be kind enough to just try whether setting nthread=1 in XGBoostClassifier fixes it as well ? This would allow to be more confident that the source of the problem is understood. I don't have xgboost installed unfortunately and I would like to avoid spending too much time on this. |
Probably relevant, from https://github.com/dmlc/xgboost/tree/master/python-package#note:
|
Of course, I'd be happy to help. Yes, that solves the issue as well (setting nthread=1). I don't have Python3 and at this point I'd rather not mess up with Python's installation. By the way, I am using MacOS and found issue #5115. Don't know enough about the system, could it be related? |
Good to know that setting nthread=1 fixes it for you. Don't worry about trying to test the solution proposed for Python 3. From the xgboost note mentioned above I am reasonably confident that it would work. I am afraid you'll have to leave with the work-around for now (either setting n_jobs=1 or nthread=1). From what I understand this is a fundamental limitation of multiprocessing in python. |
I am happy with the work-around. I just think it is useful to document it. Thank you for your time. |
If someone can edit the title to be something like "GridSearchCV with xgboost estimator hangs when n_jobs!=1" even better. |
Is there a list of know issues? Should this be added there or add a note somewhere with explained why it cannot be solved? |
We added something to the FAQ sometimes. Or we could actually have a list of known problems. |
I can confirm this! |
I don't know if this is related to #6147. I am using "The scikit-learn version is 0.18.dev0" and I have no exception though, so this is different.
In any case, this is my code (the data I am using is the same as the data for the Santander kaggle competition, too big to attach).
alg = XGBClassifier(max_depth=4, min_child_weight = 1, n_estimators=1000, learning_rate=0.0202, gamma=0, nthread=4, subsample=0.6815, colsample_bytree=0.701, seed=1, silent=False)
The program will not crash, will not throw an exception, but will not do anything (activity monitor shows no activity). Quick debugging shows the program enters
_fit
ingrid_search.py
but never reaches line 564. I did not debug further. A quick search brought me to issue #6147 and tried removing then_jobs
variable.Removing
n_jobs
from theGridSearchCV
call solves the issue.The text was updated successfully, but these errors were encountered: