Berzelius Jupyter Notebook Guide

1. Introduction

Jupyter Notebook is an open-source web application that allows you to create and share documents containing live code, equations, visualizations, and narrative text. It’s widely used in data science, scientific research, machine learning, and education for interactive computing and data analysis.

2. Installing Jupyter Notebook

Jupyter Notebook can be installed via Conda/Mamba or pip. Make sure to install it in your active Conda/Mamba environment.

# Using Conda/Mamba
mamba install jupyterlab

# Using pip
pip install jupyterlab

3. Using Jupyter Notebook via ThinLinc

After logging in through ThinLinc, you can run Jupyter Notebook in a graphical desktop environment, similar to how you would on your local computer.

  1. Open a Terminal in your ThinLinc desktop session.

  2. Load the appropriate module and activate your environment.

  3. Launch Jupyter Notebook (or JupyterLab) directly

4. Using Jupyter Notebook via SSH Tunnel

This section shows how to run Jupyter notebooks using an SSH tunnel.

4.1 Start Jupyter Notebook on Berzelius

Assume you have already installed Jupyter Notebook inside your environment. On Berzelius, first load the required module and activate your environment:

module load Miniforge3/24.7.1-2-hpc1-bdist
mamba activate pytorch_2.0.1

Start a Jupyter notebook with the no-browser flag and specify the node’s IP:

(pytorch_2.0.1) [<username>@node021 ~]$ jupyter-lab --no-browser --ip=node021 --port=9988
  • Use the --ip flag to specify the compute node (i.e., the hostname) you’re working on. You can use the command hostname to check your current hostname.
  • The port 9988 is arbitrary. If it’s already in use, try another (e.g., 9989, 9990, etc.).

You will see output similar to the following:

[I 12:36:50.243 NotebookApp] Jupyter Notebook 6.5.2 is running at:
[I 12:36:50.243 NotebookApp] http://node021:9988/?token=xxxx
[I 12:36:50.243 NotebookApp]  or http://127.0.0.1:9988/?token=xxxx
[I 12:36:50.243 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 12:36:50.256 NotebookApp] 
    
    To access the notebook, open this file in a browser:
        file:///home/username/.local/share/jupyter/runtime/nbserver-511678-open.html
    Or copy and paste one of these URLs:
        http://node021:9988/?token=xxxx
     or http://127.0.0.1:9988/?token=xxxx

4.2 Create the SSH tunnel from your Local Computer

Open a new terminal on your local computer (not on Berzelius), and run the following command:

ssh -N -L localhost:9988:node021:9988 <username>@berzelius1.nsc.liu.se

This forwards port 9988 on your local machine to the compute node’s port.

4.3 Open Jupyter Notebook in your Browser

Paste the URL (copied from the Jupyter output) into your browser on your local machine:

http://localhost:9988/?token=xxxx

Congratulations! You’ve now set up a Jupyter Notebook on Berzelius and can start working interactively.


User Area

User support

Guides, documentation and FAQ.

Getting access

Applying for projects and login accounts.

System status

Everything OK!

No reported problems

Self-service

SUPR
NSC Express