Jupyter notebook becomes unresponsive erratically

Viewed 2261

My Jupyter notebook server in an Anaconda installation stops working randomly. I haven't been able to find a pattern, but I can't spend more than 15 minutes on a notebook before the server becomes unresponsive.

Out of nowhere, a random cell hangs at [*], regardless of how simple the code is, and the page becomes unresponsive. It's not possible to restart the kernel. If I try to load another tab, Chrome gets stuck "waiting for localhost" or "waiting for available socket". Closing the prompt and opening a new notebook fixes the problem for a few minutes.

The debug log doesn't seem very helpful:

[D 19:28:32.514 NotebookApp] activity on 206ba52e-60ab-47c8-a487-18ff7ed4744f: execute_input
[D 19:28:32.515 NotebookApp] activity on 206ba52e-60ab-47c8-a487-18ff7ed4744f: execute_result
[D 19:28:32.518 NotebookApp] activity on 206ba52e-60ab-47c8-a487-18ff7ed4744f: status (idle)

I've tried:

  1. Creating a new default ipython profile
  2. Updating all my packages
  3. Removing Anaconda completely and reinstalling it
  4. Using a different browser

No dice.

Not sure if this helps, but I've noticed that sometimes (but not always, and the error still happens) I'll have a ghost notebook running without its prompt:

jupyter notebook list
Currently running servers:
http://localhost:8888/?token=885427d7798f6777ad9545bf487fd3a5dfdf52c9e446bea7 :: C:\Users\User
http://localhost:8888/?token=c3ccd0c6c255077da13e6de3c8913640cb0f985bcf31e807 :: C:\Users\User

If I try to shut them down:

jupyter notebook stop
Shutting down server on port 8888 ...
Traceback (most recent call last):
  File "C:\Users\User\anaconda3\Scripts\jupyter-notebook-script.py", line 10, in <module>
    sys.exit(main())
  File "C:\Users\User\anaconda3\lib\site-packages\jupyter_core\application.py", line 268, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "C:\Users\User\anaconda3\lib\site-packages\traitlets\config\application.py", line 664, in launch_instance
    app.start()
  File "C:\Users\User\anaconda3\lib\site-packages\notebook\notebookapp.py", line 1910, in start
    super(NotebookApp, self).start()
  File "C:\Users\User\anaconda3\lib\site-packages\jupyter_core\application.py", line 257, in start
    self.subapp.start()
  File "C:\Users\User\anaconda3\lib\site-packages\notebook\notebookapp.py", line 466, in start
    if not self.shutdown_server(server):
  File "C:\Users\User\anaconda3\lib\site-packages\notebook\notebookapp.py", line 457, in shutdown_server
    return shutdown_server(server, log=self.log)
  File "C:\Users\User\anaconda3\lib\site-packages\notebook\notebookapp.py", line 417, in shutdown_server
    HTTPClient().fetch(req)
  File "C:\Users\User\anaconda3\lib\site-packages\tornado\httpclient.py", line 133, in fetch
    functools.partial(self._async_client.fetch, request, **kwargs)
  File "C:\Users\User\anaconda3\lib\site-packages\tornado\ioloop.py", line 532, in run_sync
    return future_cell[0].result()
tornado.simple_httpclient.HTTPTimeoutError: Timeout during request

I'm completely at loss! Any guidance would be appreciated.

1 Answers

After googling I found out that , you should try to "wipe the cache", by closing my jupyter notebook, deleting all the .ipynb_checkpoints this notebook and reloading the page. That worked, but was rather drastic.


I had a similar problem in my laptop . This is not a usual fix for any problem . Since your notebook freezes irrespective of simple your code is , I can suggest you to do what I did.

It's specifications were :

Processor : Intel(R) Core(TM) i5-8250 CPU @ 1.60 Ghz  1.80 Ghz
Ram : 8 GB
System type : 64-bit , x64 based processor

However , when upgraded to my new laptop with specifications :

Processor: 8th Gen Intel Core i5-8300H Processor base speed 2.3GHz (8M Cache, up to 
           3.9GHz, 4 Cores)
Memory: 8GB DDR4 2666MHz RAM ( was the original one but I replaced it with a 32 GB  RAM

I had stopped encountering the said problem . So I believe upgrading your RAM of your system , or starting it in a system with more CPU's , should solve your problem .

Related