cmo*_*sig 7 python multiprocessing joblib
我只使用基本的 joblib 功能:
Parallel(n_jobs=-1)(delayed(function)(arg) for arg in arglist)
Run Code Online (Sandbox Code Playgroud)
我经常收到警告:
UserWarning: A worker stopped while some jobs were given to the executor. This can be caused by a too short worker timeout or by a memory leak.
Run Code Online (Sandbox Code Playgroud)
这告诉我一个可能的原因是工作超时时间太短。由于我没有设置工作超时并且默认为None,因此这不是问题。我如何去寻找内存泄漏?或者我可以做些什么来避免这个警告?有些部分没有得到执行?或者我不应该担心这个?
为了解决这个问题,增加超时,我使用了这个:
# Increase timeout (tune this number to suit your use case).
timeout=99999
result_chunks = joblib.Parallel(n_jobs=njobs, timeout=timeout)(joblib.delayed(f_chunk)(i) for i in n_chunks)
Run Code Online (Sandbox Code Playgroud)
请注意,此警告是良性的;joblib 将恢复并且结果完整且准确。
请参阅此处更详细的答案。