Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restart kernel in Google Colab

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,

like image 783
Gustavo Mirapalheta Avatar asked Mar 05 '19 14:03

Gustavo Mirapalheta


Video Answer


1 Answers

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()
like image 153
Qbert Avatar answered Oct 24 '22 06:10

Qbert