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.
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
After logging in through ThinLinc, you can run Jupyter Notebook in a graphical desktop environment, similar to how you would on your local computer.
Open a Terminal in your ThinLinc desktop session.
Load the appropriate module and activate your environment.
Launch Jupyter Notebook (or JupyterLab) directly
This section shows how to run Jupyter notebooks using an SSH tunnel.
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
--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.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
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.
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.
Guides, documentation and FAQ.
Applying for projects and login accounts.