Springe direkt zu Inhalt

JupyterLab

Introduction

JupyterLab is a web-based user interface for Project Jupyter which allows interaction with documents and activities such as Jupyter notebooks, text editors, and terminals.

JupyterLab should not be started on the login node.  Instead it should be run on a compute node.  This can be done using the following approach.

Create a password

The following needs to be done only once.

On the login node of the HPC cluster, run the commands below.  You will be prompted to generate a password, which you will use later to access JupterLab.

module add JupyterLab/4.0.5-GCCcore-12.3.0
jupyter lab --generate-config
jupyter lab password

Submit batch job

Use the following script as a template and submit it via sbatch as a normal job.

#!/bin/bash                                                                                                                                                                                   

#SBATCH --job-name=jupyter-notebook                                                                                                                                                           
#SBATCH --nodes=1                                                                                                                                                                             
#SBATCH --ntasks=1                                                                                                                                                                            
#SBATCH --cpus-per-task=8                                                                                                                                                                  
#SBATCH --mem=20G                                                                                                                                                                             
#SBATCH --gres=gpu:1                                                                                                                                                                          
#SBATCH --qos=hiprio                                                                                                                                                                          
#SBATCH --partition=gpu                                                                                                                                                                       
#SBATCH --time=3:00:00                                                                                                                                                                        

# Get tunneling information                                                                                                                                                                   
XDG_RUNTIME_DIR=""
node=$(hostname -s)
port=`python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'`

# Tunneling instructions                                                                                                                                                                      
echo -e "                                                                                                                                                                                     
On your local computer, create an SSH tunnel:                                                                                                                                                 
                                                                                                                                                                                              
  ssh -N -f -L ${port}:${node}:${port} ${USER}@curta.zedat.fu-berlin.de                                                                                                                       
                                                                                                                                                                                              
On your local computer, point a browser to:                                                                                                                                                   
                                                                                                                                                                                              
  http://localhost:${port}              

and enter the password you created earlier.                                                                                                                                                      
                                                                                                                                                                                              
"

# Load modules and run JupyterLab                                                                                                                                                             
module add JupyterLab/4.0.5-GCCcore-12.3.0
jupyter lab path
jupyter-lab --no-browser --port=${port} --ip=${node}

Connect to JupyterLab

Follow the instructions which are given in the output file of the job.

Keywords