Skip to main content

Jupyter

The instructions on this page illustrate how to set up JupyterLab for use on Hamilton.

Install JupyterLab in your Hamilton account

JupyterLab is not installed centrally on Hamilton so you will need to install a copy in your own account. Conda can be used for this. If you do not already have conda installed, download the miniforge installer:

wget https://github.com/conda-forge/miniforge/releases/latest/download/\
Miniforge3-Linux-x86_64.sh

Then run the installer as below. When prompted, you may wish to specify a location in /nobackup as the installation directory, but remember that /nobackup files are not backed up.  Allowing the installer to initialise Miniforge will let you use conda immediately and in future login sessions.

bash Miniforge3-Linux-x86_64.sh

Use conda to install JupyterLab:

conda install -c conda-forge jupyterlab

Finally, set a password:

jupyter-server --generate-config

jupyter-server password


Configure your session

Jupyter can be run either on a login node or one of the compute nodes. The login nodes are suitable if you only need to do light work in Jupyter. However, they are shared by all users so intensive computations should not be done here. If you want to run anything intensive within Jupyter, you will need to do that on the compute nodes.

Follow the steps in Case 1 (login node) or Case 2 (compute node) so that your Jupyter session can be displayed using a browser on your local computer.  You will need to do these steps each time you want to use Jupyter on Hamilton.

Case 1 - running on a Hamilton login node

1. Hamilton has two login nodes, called “login1” and “login2”. Select one of these to use.

2. At a command prompt on your local machine, set up port-forwarding:

ssh -L<port>:localhost:<port> <username>@<node>.ham8.dur.ac.uk

where <node> is the login node name and <port> is a 4-digit number of your choice.  The default port is 8888; choose a different number to avoid conflicts with other people:

3. You should now be logged into a login node.  On that node, run:

jupyter lab --no-browser --port=<port> # use the same port number as above

4. Copy the URL given at the bottom of the Jupyter output.

5. On your local computer, paste into your browser the URL you copied above.

6. When you have finished with your Jupyter server, please remember to end it to release the resources.


Case 2 - running on a Hamilton compute node.

You will need to use the scheduler (Slurm) to allocate resources on a compute node.  This example uses an interactive Slurm job, which will work if space is available when you need it; an alternative would be to adapt the instructions to form a batch job and wait for it to start.

1. Login to Hamilton.  Note the name of the login node you are connected to, e.g. "login1".

2. At your Hamilton command prompt, use Slurm to start an interactive shell on a compute node. You can add more time and resources if need be (see Running jobs):

srun --pty -c 1 --mem=1G -t 01:00:00 bash

Note: the interactive job will only be able to start when there is space for it.

3. Once the interactive shell has started, your command prompt will contain the name of the compute node, which will begin with 'cn', e.g.cn001. Note this name.

4. On the compute node, type:

jupyter lab --no-browser --ip=* --port=<port> 

where <port>is a 4-digit number of your choice.  The default is 8888; choose a different number to avoid conflicts with other people

5. Copy the URL given at the bottom of the Jupyter output.

6. At a command prompt on your local computer, set up port-forwarding, choosing login1 or login2 to match the login node where you ran the srun command above, and the same port number as in step 4.

ssh -L<port>:<compute node name>:<port> <username>@login<1 or 2>.ham8.dur.ac.uk

e.g. ssh -L<port>:cn001:<port> <username>@login1.ham8.dur.ac.uk

7. On your local computer, paste into your browser the URL you copied above.

8. When you’ve finished with your notebook server, please remember to end it to release the resources. If not ended manually, the server processes will be killed when the job times out.