Reconnect to jupyter notebook while training

Hi, I am currently using a google compute instance along with a jupyter notebook to train my models. However, this requires me to keep the jupyter notebook open on my computer the whole time. Is there any way I can set up something where I can close my laptop, open it back up again and I can just ssh into the instance and see how the model is training on the notebook. Thanks!

You can use tmux. Open up a fresh terminal, and reconnect to your machine via ssh. Then just type tmux, and that will launch a new session. Then launch your Jupiter Notebook.

Now if you ctrl+c out of the ssh session your port forwarding is running through, it will say you have disconnected, but the Jupiter notebook will continue to execute. And, as long as the original browser window is still open, you can do Kernal > Reconnect to connect back to your notebook, and it’ll be like you never left. If for some reason the browser window closes, you won’t be able to see live output, but you can check your data directory to see when the weights save, and then just refresh your notebook.

7 Likes

I suffer the Reconnection problem when i reconnect my bad network.
Reconnect from kernel not doing well for job done but processing status not done([*] not specific [num]). Any one have a solution?

This could be interesting: https://stackoverflow.com/questions/35932019/losing-jupyter-notebook-ssh-connection-kills-kernel

I am now playing with screens.

Edit:
I am using now screens all the time to connect to my machine, e.g. for running the jupyter notebook server, long downloads, etc., which you can easily resume with screens after you got disconnected with ssh.

Here you go with a essential intro for using it:

To create a screen session:
screen

or to create a named screen session:
screen -S <name>

To show all opened screens:
screen -ls

Reattach to detached screen, if there is only one screen <screen> is not needed:
screen -r <screen>

Reattach to attached screen:
screen -x <screen>

To exit:
exit

1 Like