Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Persistent use of Jupyter Notebook from remote server

Tags:

I connect to a remote server using ssh -L but if I close the laptop lid or the connection is lost, the jupyter notebook is disconnected.

After I reconnect to the remote server, the "last" session is lost.

What can be done to make it persistent? Could screen help with it?

like image 814
Michael D Avatar asked Aug 23 '17 09:08

Michael D


People also ask

Can you use jupyter notebook from remote server?

you can run jupyter notebook --no-browser --ip="<remote server ip>" on your remote machine terminal. And access notebooks using http://:8888/?token=<> from your browser on local machine.

How do you run a jupyter notebook everyday?

How do I schedule a Jupyter Notebook to run? When your Jupyter notebook is ready for scheduling, open the Schedule runs option inside the Computation tab or access it from the Run menu in Datalore. Then choose the run interval (hourly, daily, weekly, monthly) and the time zone.

How do you make Jupyter notebooks run automatically?

Open a Jupyter notebook from the left sidebar. Click on the Scheduler icon either from the left sidebar tab or from the top toolbar of the Jupyter notebook. The left sidebar displays the Schedule(s) and Run History tabs as shown below. To view the active schedules, click Schedule(s) tab.


2 Answers

On the remote server, you should open your jupyter in a screen session, it will make it persistent if you lose the connection to the server and resume it.

  1. On your computer: ssh -L xxxx:localhost:yyyy server.
  2. screen.
  3. jupyter notebook --no-browser --port=yyyy. [on remote server]
  4. In your browser: localhost:xxxx.

To disconnect manually and reconnect:

  1. Exit the screen window: control + a and then d.
  2. Disconnect from the server: control + d
  3. And reconnect ssh -L xxxx:localhost:yyyy.
  4. Optionally, you can reopen the screen window, though unnecessary, using screen -r.
  5. Go back to your notebook or reopen localhost:xxxx.
like image 63
BiBi Avatar answered Oct 29 '22 06:10

BiBi


The standard usage for persisting Jupyter server sessions is the use of nohup and &; in your remote server with IP address xx.xx.xx.xx:

nohup jupyter notebook --no-browser --ip xx.xx.xx.xx --port yyyy & 

Now, even if you switch off your laptop or lose the connection, you will be always able to reconnect by pointing your browser at xx.xx.xx.xx:yyyy

like image 41
desertnaut Avatar answered Oct 29 '22 07:10

desertnaut