Using Jupyter at HPC2N

Running JupyterLab at HPC2N

Since the JupyterLab will only be accessible from within HPC2N's domain, it is by far easiest to do this from inside ThinLinc, so this is highly recommended. You can find information about using ThinLinc at HPC2N here: https://www.hpc2n.umu.se/documentation/guides/thinlinc

For a page about how to use Jupyter with extra Python packages, see this page.

For a page about how to use Jupyter with Julia, see this page.

For a page about how to use Jupyter with R, see this page.

1) At HPC2N, you currently need to start JupyterLab on a specific compute node. To do that you need a submit file and inside that you load the JupyterLab module and its prerequisites (and possibly other Python modules if you need them - more about that later).

NOTE: HPC2N and most other HPC centers in Sweden use modules to handle their software. You can read more about modules here: https://www.hpc2n.umu.se/documentation/environment/lmod

To see the currently available versions, do

module spider JupyterLab

You then do

module spider JupyterLab/<version>

for a specific <version> to see which prerequisites should be loaded first.

Example, loading JupyterLab/3.2.8

module load GCC/10.3.0 JupyterLab/3.2.8

2) Making the submit file

Something like the file below will work. Remember to change the project id, how many cores you need, and how long you want the JupyterLab to be available:

#!/bin/bash
# Here you should put your own project id
#SBATCH -A hpc2nXXXX-YYY
# This example asks for 1 core
#SBATCH -n 1
# Ask for a suitable amount of time. Remember, this is the time the Jupyter notebook will be available! HHH:MM:SS.
#SBATCH --time=05:00:00
 
# Clear the environment from any previously loaded modules
module purge > /dev/null 2>&1
 
# Load the module environment suitable for the job
module load GCC/10.3.0 JupyterLab/3.2.8

# Start JupyterLab
jupyter lab --no-browser --ip $(hostname)

 

Where the flags used to the Jupyter command has the following meaning (you can use Jupyter --help and Jupyter lab --help to see extra options):

  • lab: This launches JupyterLab computational environment for Jupyter.
  • --no-browser: Prevent the opening of the default url in the browser.
  • --ip=<IP address>: The IP address the JupyterLab server will listen on. Default is 'localhost'. In the above example script I use $(hostname) to get the content of the environment variable for the hostname for the node I am allocated by the job.

Note again that the JupyterLab is only accessible from within the HPC2N domain, so it is easiest to work on the ThinLinc.

3) Submit the above submit file. Here I am calling it MyJupyterLab.sh

sbatch MyJupyterLab.sh

4) Get the URL from the SLURM output file.

Wait until the job gets resources allocated. Check the SLURM output file; when the job has resources allocated it will have a number of URLs inside at the bottom.

The SLURM output file is as default named slurm-<job-id>.out where you get the <job-id> when you submit the SLURM submit file (as in item 3) here). 

NOTE: Grab the URL with the hostname since the localhost one requires you to login to the compute node and so will not work!

The file will look similar to this:

b-an01 [~]$ cat slurm-22422626.out
[I 2023-05-11 15:06:23.597 ServerApp] jupyterlab | extension was successfully linked.
[I 2023-05-11 15:06:23.756 LabApp] JupyterLab extension loaded from /hpc2n/eb/software/JupyterLab/3.2.8-GCCcore-10.3.0/lib/python3.9/site-packages/jupyterlab
[I 2023-05-11 15:06:23.756 LabApp] JupyterLab application directory is /cvmfs/ebsw.hpc2n.umu.se/amd64_ubuntu2004_bdw/software/JupyterLab/3.2.8-GCCcore-10.3.0/share/jupyter/lab
[I 2023-05-11 15:06:23.760 ServerApp] jupyterlab | extension was successfully loaded.
[I 2023-05-11 15:06:23.761 ServerApp] Serving notebooks from local directory: /pfs/stor10/users/home/b/bbrydsoe
[I 2023-05-11 15:06:23.761 ServerApp] Jupyter Server 1.13.4 is running at:
[I 2023-05-11 15:06:23.761 ServerApp] http://b-cn0232.hpc2n.umu.se:8888/lab?token=4e369c85f797f7de0c4e15723af75e93ad6bbe7cba11ae59
[I 2023-05-11 15:06:23.761 ServerApp]  or http://127.0.0.1:8888/lab?token=4e369c85f797f7de0c4e15723af75e93ad6bbe7cba11ae59
[I 2023-05-11 15:06:23.761 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 2023-05-11 15:06:23.778 ServerApp]
    
    To access the server, open this file in a browser:
        file:///pfs/stor10/users/home/b/bbrydsoe/.local/share/jupyter/runtime/jpserver-173465-open.html
    Or copy and paste one of these URLs:
        http://b-cn0232.hpc2n.umu.se:8888/lab?token=4e369c85f797f7de0c4e15723af75e93ad6bbe7cba11ae59
     or http://127.0.0.1:8888/lab?token=4e369c85f797f7de0c4e15723af75e93ad6bbe7cba11ae59

 

In this case you should use this one:

http://b-cn0232.hpc2n.umu.se:8888/lab?token=4e369c85f797f7de0c4e15723af75e93ad6bbe7cba11ae59

5) Start a webbrowser within HPC2N (ThinLinc interface). Put in the URL you grabbed, including the token:

jupyterlab-start.png

After a few moments JupyterLab starts up:

jupyterlab_started.png

You shut it down from the menu with "File" -> "Shut Down"

Updated: 2024-06-15, 11:05