Skip to content

Jupyter

In order to use Jupyter notebooks on DelftBlue you will need to do the following:

Install your own Jupyterlab in conda

1) Connect to Delftblue

ssh <netid>@login.delftblue.tudelft.nl

2) Load modules:

module load 2022r2
module load openmpi
module load miniconda3

3) Make sure your conda saves everything to /scratch:

mkdir -p /scratch/${USER}/.conda
ln -s /scratch/${USER}/.conda $HOME/.conda

4) Create a new conda environment and install jupyterlab:

conda create --name jupyterlab
conda activate jupyterlab
conda install -c conda-forge jupyterlab

Submit your jupyter job to run on one of the compute nodes

5) Create a new submission script, e.g. jupyterlab.sh:

#!/bin/bash

#SBATCH --job-name=jupyter
#SBATCH --partition=compute
#SBATCH --time=02:00:00
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=4
#SBATCH --mem-per-cpu=1G
#SBATCH --account=research-faculty-department

# Load modules:
module load 2022r2
module load openmpi
module load miniconda3

# Set conda env:
unset CONDA_SHLVL
source "$(conda info --base)/etc/profile.d/conda.sh"

conda activate jupyterlab
cat /etc/hosts
jupyter lab --ip=0.0.0.0 --port=8888
conda deactivate

6) Submit your job:

sbatch jupyterlab.sh

7) Make sure the job is running:

[dpalagin@login04 jupyterlab]$ squeue --me
             JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)
           2067459   compute  jupyter dpalagin  R      15:49      1 cmp047

Check which node the job is running on, and how to connect to it

8) Check the output in your slurm-XXX.out file:

cat slurm-XXX.out

You will find something along these lines:

[I 2023-02-22 09:25:13.233 ServerApp] Jupyter Server 2.3.0 is running at:
[I 2023-02-22 09:25:13.234 ServerApp] http://cmp047:8888/lab?token=0f42f2d94b981b3f0d972586762a72601a9477d18747f33a
[I 2023-02-22 09:25:13.234 ServerApp]     http://127.0.0.1:8888/lab?token=0f42f2d94b981b3f0d972586762a72601a9477d18747f33a
[I 2023-02-22 09:25:13.235 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 2023-02-22 09:25:13.336 ServerApp]

    To access the server, open this file in a browser:
        file:///home/dpalagin/.local/share/jupyter/runtime/jpserver-3094075-open.html
    Or copy and paste one of these URLs:
        http://cmp047:8888/lab?token=0f42f2d94b981b3f0d972586762a72601a9477d18747f33a
        http://127.0.0.1:8888/lab?token=0f42f2d94b981b3f0d972586762a72601a9477d18747f33a
gio: file:///home/dpalagin/.local/share/jupyter/runtime/jpserver-3094075-open.html: No application is registered as handling this file

9) On your computer, open a new Terminal Window and create an SSH tunnel:

ssh -L 8888:cmp047:8888 <netid>@login.delftblue.tudelft.nl

Important: You must replace the node name (cmp047) in the command below with the node your job is running on.

Open your browser, and start Jupyter

10) Now that your job is running, and the tunnel to the node it is running on is open, we can start our local jupyter window. To do that, jsut open your internet browser, and copy the URL which you found in the slurm-XXX.out. e.g.

http://127.0.0.1:8888/lab?token=0f42f2d94b981b3f0d972586762a72601a9477d18747f33a

11) You are good to go!

Jupyter is running