Multiprocessing backed parallel loops cannot be nested below threads

大城市里の小女人 提交于 2019-11-28 11:06:15

This seems to be due to this issue in JobLib library. At the moment of writing this seems to be fixed but not released yet. As written in the question, a dirty fix would to rename the main thread back to MainThread:

threading.current_thread().name = 'MainThread'

I had the same warning while doing predictions with sklearn within a thread, using a model I loaded and which was fitted with n_jobs > 1. It appears when you pickle a model it is saved with its parameters, including n_jobs.

To avoid the warning (and potential serialization cost), set n_jobs to 1 when pickling your models:

clf = joblib.load(model_filename).set_params(n_jobs=1)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!