papermill: `RuntimeError: Kernel didn't respond in 60 seconds`, when trying to run papermill with python multiprocessing
Hello, I am trying to run multiple parameterized notebooks in parallel. Currently, I am using papermill inside Jupyter Notebook and if I try to use multiprocessing pool to map a list of parameters as pass them to pm.execute_notebook, I get RuntimeError: Kernel didn't respond in 60 seconds. I am running everything with Python 2.7.
This is the code I use:
import papermill as pm
import multiprocessing as mp
def run_nb(data):
d1, d2 = data
pm.execute_notebook(in_nb, out_nb, parameters = dict(d1=d1, d2=d2) )
pool = mp.Pool(4)
pool.map(run_nb, zip(data1, data2))
pool.close()
pool.join()
It works correctly using the standard python map.
Btw, is there a known way to produce multiple notebooks in parallel with papermill?
Thanks!
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 18 (9 by maintainers)
Hi, I might just be overlooking something, but I think I’m still experiencing this issue even after upgrading nbconvert. It seems to be an upstream issue with nbconvert, because I get the same issues when calling the execute API directly. Let me know if I should migrate this question to that repository.
To replicate:
test.ipynbhas a single cell that prints the word “testing”. The following works fine:But the following two code snippets each break
with error code
RuntimeError: Kernel didn't respond in 60 secondsin the first case andRuntimeError: Kernel didn't respond in 300 secondsin the second.I’m using Python 3.7. I’ve been able to replicate this with both nbconvert 5.6.0 and 5.6.1.
Thanks!
Wondering: what is the status for this issue? I can confirm that this problem is still present in Python3 when using Papermill. Will multiprocessing become doable with Papermill?
This base issue should now be resolved with the nbconvert 5.6.0 release!
FWIW, this problem also affects papermill on jupyter in python 3.
Hi @franzoni315
So it looks like there’s race conditions in the ipython kernel launching parallel processes. Using a threadpool instead get’s to run more often without hanging but any high parallelism doesn’t beat the race conditions. I ran a few times under different conditions and eventually got
And
I also noticed the race conditions onexit occur every run and are causing session saves to fail (nbd but points to the reuse of
session_numberwhich overlaps).I can also reproduce this failure with a simple bash for loop over papermill. I’ll open up a ticket on the ipython project to figure out what the root cause is and see if there’s a change in papermill that would fix this.
It will become doable – we need a release for multiple upstream libraries and there’s still one pending PR testing an edge case we haven’t fixed for one of those releases. Give the community a couple weeks more here, there’s a lot of moving parts and it’s been unsupported for a long time in the upstream projects. You can pay attention to nbconvert 5.5.1 release announcement on Discourse and on the jupyter mailing list. That will be the last release to get it resolved.