sklearn库中GridSearchCV方法打包为exe方法后报错:joblib.externals.loky.process_executor.TerminatedWorkerError
将sklearn库中GridSearchCV方法,使用pyinstaller打包为exe方法后报错:joblib.externals.loky.process_executor.TerminatedWorkerError: A worker process managed by the executor was unexpectedly terminated. This could be caused by a segmentation fault while calling the function or by an excessive memory usage causing the Operating System to kill the worker.
查询了诸多方法,可能是系统线程和进程的一些区别导致的问题。
最后在github上找到答案,主要是joblib库的一些bug
https://github.com/joblib/joblib/issues/1002
简单来说,在训练代码前加入代码:
with parallel_backend('multiprocessing'):
grid_search.fit(X_train, y_train)
即可解决打包的问题