Jupyter Notebook and Jupyter Lab with srun¶
Recommended approach
The easiest and recommended way to run Jupyter on BMRC is through Open OnDemand, which handles session management, port forwarding, and environment setup automatically — no terminal tunnelling required.
The manual method described on this page is useful when you need finer control over your session (e.g. memory layouts, or debugging environment issues outside of OnDemand).
Prerequisites¶
Before starting, make sure you have:
- Access to
JupyterLab/4.5.6-GCCcore-12.3.0module ( or anyJupyterLab> 4.5.6 which have all of the required extensions pre-installed ) -
OR If you prefer to use your own Python virtual environment and not the module, create one according to these instructions and install both
JupyterLabandnotebook
Step 1 — Start an interactive session¶
Log into any of the BMRC login nodes and request an interactive node. For example, 2 CPUs and 30 GB of memory on the short partition:
Once the session starts, note the hostname of the node you have been assigned:
Step 2 — Load JupterLab module OR activate your Python virtual environment¶
Load the Python module and activate the matching virtual environment. Select the tab for the toolchain you are using:
Step 3 — Start the Jupyter server¶
Change into the directory where your notebooks are stored, then launch the server. Select the tab for the interface you want:
Once the server starts you will see output similar to:
I 2026-05-08 18:53:03.587 ServerApp] jupyter_lsp | extension was successfully linked.
[I 2026-05-08 18:53:03.592 ServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2026-05-08 18:53:03.596 ServerApp] jupyterlab | extension was successfully linked.
[I 2026-05-08 18:53:03.600 ServerApp] notebook | extension was successfully linked.
[I 2026-05-08 18:53:04.492 ServerApp] notebook_shim | extension was successfully linked.
[W 2026-05-08.....................
.........................
To access the server, open this file in a browser:
...
Or copy and paste one of these URLs:
http://localhost:8888/lab?token=b358a08f791d96bdd3ff8139a...............
http://127.0.0.1:8888/lab?token=b358a08f791d96bdd3ff8139a...............
Note down two things
- The port number (e.g.
8888) — it may differ if that port is already in use on the node. - The full URL beginning with
http://127.0.0.1:— you will paste this into your browser later.
Step 4 — Create an SSH tunnel¶
On your local machine (not the cluster), open a new terminal and run:
- If you have setup the local terminal
~/.ssh/configaccording to these instructions, replaceusername@cluster1.bmrc.ox.ac.ukwith the shorter hostname .i.e.bmrc1,etc.
Substitute:
| Placeholder | Replace with |
|---|---|
8888 (first) |
Your local port — change this if 8888 is already in use locally |
compe023 |
The node hostname from Step 1 |
8888 (second) |
The port Jupyter is listening on (from Step 3) |
cluster1 |
cluster2 if that is where your session is running |
username |
Your BMRC username |
Port already in use locally?
If port 8888 is already occupied on your laptop, use a different local port,
for example 9999:
In this case you must also change the port in the URL you paste into your browser (see Step 5).
The tunnel command will open a normal-looking SSH session. Leave this terminal open for as long as you need to use Jupyter.
Step 5 — Open Jupyter in your browser¶
Copy the http://127.0.0.1:... URL from Step 3 and paste it into a browser on
your local machine. Jupyter will load.
Changed your local port?
If you used a different local port (e.g. 9999) in Step 4, edit the port in
the URL before opening it:
Ending your session¶
When you are finished:
- Shut down the Jupyter server from the Lab/Notebook interface, or press
Ctrl+Ctwice in the terminal running the server. - If you were using a
Pythonvirtual environment, deactivate the virtual environment:deactivate - Exit the interactive Slurm session:
exit - Close the SSH tunnel terminal.
Tip
Leaving an interactive Slurm session idle wastes cluster resources and counts against your allocation. Always exit when you are done.