Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

What to do when Jupyter suddenly hangs?

Writer Sophia Terry

I'm using Jupyter notebook 4.0.6 on OSX El Capitan.

Once in a while I'll start running a notebook and the cell will simply hang, with a [ * ] next to it and no output.

When this happens, I find that only killing Jupyter at the command line and restarting it solves the problem. Relaunching the kernel doesn't help.

Has anyone else had this problem? If so, any tips?

1

5 Answers

That usually happens when I edit the program after leaving the output running mid-way and then run it again. This will cause the kernel to get struck. I generally just restart the kernel and then it works fine.

To restart the kernel,press Esc to enter command mode, then press 0 0 (zero) to restart the kernel, now your program will run.

To avoid this in the future, remember to complete the execution of your program before editing the code.

If you have been training a large neural network for a long time and then this has happened, you should just wait till the time you expect the process to finish.

Screenshot of the same happening to me

In this image, you can clearly see that the output is frozen on 3rd epoch but the weights have been saved till 14th epoch and the program is still running.

I am facing the same problem recently, that jupyter notebook often stucks without any reason, even when executing very simple code (such as x = 1), so there was no possibility that I fell into an infinite loop.

I noticed that every time this situation occurred, there was a solid circle on the top right of the page which meant the kernel was busy and working, but it was abnormal that the jupyter took over twenty seconds to process the code like x = 1. I need to wait for several minutes to see if the kernel would come back, while sometimes it never come back, so I have to shut down and restart the kernel with losing all of my data. It is weird that although the kernel sometimes takes a long time to come back on itself, there would be literally NO output, instead "ln []" would be shown in front of that block. Besides, since I am using the extension ExecuteTime, so that I am able to see how long it takes jupyter to execute a code block, and when this awful situtation happens, it turns out

executed in 0ms, finished 01:38:14 2022-03-31

I guess it may be raised by problems of memory, because it seems to have higher frequency when I am processing large datasets or may be due to the unknown incompatibility with nbextensions, as references for other people who meet the same issues.

I use Jupyter Notebook 4.2.3 on OSX El Capitan, so I might not be really helpful, but at least I can try to guess.

[*] basically means that something is going on, so if you are running a script with some complicated computations, you'd better wait a little bit.

To make sure, you may try to use a loading bar that can help you to control the process. A good one is suggested here. Otherwise, you can check out other notebooks with loading bars illustrating any processes by default. Apache Zeppelin should have such feature.

We can interrupt the kernel.

The [*] symbol means the cell is being processed by the kernel and the process is not complete. Check for infinite loops or recursive functions there. Working with very large data frames and inefficient pandas commands could also be the culprit

This is a bottleneck when we have large data frames already loaded into memory while running earlier cells in the notebook.

We can simply interrupt the kernel, use I, I command for that. But be patient. Top right circle should turn white instead of black.

Here you can interrupt the kernel

Another nice trick I learnt is to reload the libraries using importlib incase I install a different one or change a custom python script where I wrote some handy functions. like thisreload libraries

This way we need not run the entire notebook from start which may/may not take a long time.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy