Using Jupyter Notebook on Berzelius

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.

Installing Jupyter Notebook

Jupyter Notebook can be installed via Conda/Mamba or pip.

# Using Conda/Mamba
mamba install jupyter

# Using pip
pip install jupyterlab

Running Jupyter Notebook via SSH forwarding

Jupyter notebooks can be used via ThinLinc (see Running Graphical Applications) or SSH port forwarding. Following is an example for running Jupyter Notebook via SSH port forwarding.

Assume that you have installed Jupyter Notebook in your Conda/Mamba environment. On a compute node, activate your environment:

module load Mambaforge/23.3.1-1-hpc1-bdist
mamba activate pytorch_2.0.1

Start a Jupyter notebook with the no-browser flag:

(pytorch_2.0.1) [<username>@node021 ~]$ jupyter-lab --no-browser --ip=node021 --port=9988

Please use the --ip flag to specify the node that you are working on.

The port 9988 is arbitrary. If 9988 is already in use, then just try 9989, etc.

You will see the following info printed out on your terminal:

[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

Open a new local terminal, make a SSH tunnel login:

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

Start your favorite browser on your local computer, paste the following URL given by the jupyter-notebook on Berzelius:

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

Congratulations! You’ve now set up a Jupyter Notebook.


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