Restart kernel in Google Colab

Gustavo Mirapalheta picture Gustavo Mirapalheta · Mar 5, 2019 · Viewed 10k times · Source

I´m trying to restart the kernel in a Google Colab Jupyter Notebook through a cell. The option given previously:

import os
os._exit(00)

is ok, but it seems to me that this is not a very "pythonic" way of restarting the kernel. The other option:

from IPython.core.display import HTML
HTML("<script>Jupyter.notebook.kernel.restart()</script>")

seems more "pythonic" (better) to me, but it is not working.

Is there something specific to Google Colab that I should have done?

Best regards,

Gustavo,

Answer

Qbert picture Qbert · May 17, 2019

Just go to "Runtime" in the option menu then click on "Reset all runtimes..".

It helps me to restart kernel as in jupyter notebook happen when i'm trying to run this:

tf.executing_eagerly()