How to RE-connect to a Remote Jupyter instance (Running Code)

961 views Asked by At

I have several long running scripts (in Jupyter Notebook) on a remote Google Cloud Compute Instance.

If I lose the ssh connection, I cannot reconnect to the (running) Notebook without stopping those running scripts--executing within the Notebook.

It seems that closing my macbook, will sever my connection to the remote (running) jupyter notebook. Is there some way to reconnect without stopping the script?

On Google Cloud, Jupyter is still running. I just can't connect to the notebook executing the code––without stopping code execution.

I'm sure other Jupyter users have figured this out :) Thanks in advance

My GCloud Tunneling Script

gcloud compute ssh --zone us-central1-c my-compute-instance -- -N -p 22 -D localhost:5000

Bash Script that Launches Chrome

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
"localhost:22"     
--proxy-server="socks5://localhost:5000"
--host-resolver-rules="MAP * 0.0.0 , EXCLUDE localhost"
--user-data-dir=/tmp/

Nohup that launches Jupyter on Gcloud

nohup jupyter notebook --no-browser > log.txt 2>&1 &
  • On my Sierra-os macbook, no proxy settings (System Preferences) are enabled
  • On Google Cloud, I'm NOT using a static ip, just an ephemeral ip.

Much appreciation in advance

1

There are 1 answers

0
Matt On BEST ANSWER

What do you mean by "cannot reconnect" ? Do you mean you can't see the notebook interface anymore ? (In which case this is likely a google cloud question).Or do you mean you can't run code or see previous results ?

If the second, this is a known issue, the jupyter team is working on it; The way to go around that is to wrap your code in Python Futures, that store intermediate code; thus re-accessing the future will not trigger re-computation, but will show you intermediate results.