Using Jupyter Notebooks

Jupyter Notebooks can be run on the compute nodes and connected to via a browser on a login node (in a NoMachine session), or even on a local computer via a SSH tunnel.

Starting Jupyter

The command to start a Jupyter Lab or Notebook on a compute node should be as below. This prevents Jupyter from trying to start a browser itself and forces the server to listen on the main network interface on a randomised port.

jupyter-lab --no-browser --ip=$(hostname) --port=$(( $RANDOM % 65536 + 6000 ))

Connecting to Jupyter from a Login Node

Once started, Jupyter will report the URLs for connecting to it, an example below shows it running on the compute node alice-node099 and port 32858:

    To access the server, open this file in a browser:
        file:///alice-home/1/l/ljg2/.local/share/jupyter/runtime/jpserver-1698723-open.html
    Or copy and paste one of these URLs:
        http://alice-node099:32858/lab?token=3d76072a9ab5b90abc
        http://127.0.0.1:38284/lab?token=3d76072a9ab5b90abc

We're only interested in the http://alice-node099 URL.

The URL can be used directly in Firefox running on a login node to connect to the running Jupyter notebook.

Connecting to Jupyter via a SSH Tunnel

The URL on the compute node that Jupyter reports can be connected to on a local PC's browser via a SSH tunnel. In the case of the example above a SSH tunnel through ALICE to alice-node099 port 32858 must be created.

With OpenSSH a tunnel listening on the local PC port (8888 in this example) would be created as so:

ssh -L 8888:alice-node099:32858 ljg2@alice.le.ac.uk

Normal ALICE authentication is required, but once logged in a local browser will be able to connect to http://localhost:8888/lab?token=3d76072a9ab5b90abc