Marimo Notebook
Marimo notebooks are modern alternative to Jupyter Notebooks. Basic overview of its capabilities can be found in this blog post.
Run Marimo Notebook on Vega
To run and use Marimo Notebook on Vega please follow the instruction below:
-
Login to Vega gpulogin node
-
Book a compute node on Vega login node
salloc -n 1 --gres=gpu:1 --mem=40G --partition=gpu -t 4:00:00
The output of this command will show which gpu node is assigned. In this case allocated node is gn03.
[user@vglogin0005 ~]$ salloc -n 1 --gres=gpu:1 --mem=40G --partition=gpu -t 4:00:00
salloc: Pending job allocation 24529170
salloc: job 24529170 queued and waiting for resources
salloc: job 24529170 has been allocated resources
salloc: Granted job allocation 24529170
salloc: Waiting for resource configuration
salloc: Nodes gn03 are ready for job
bash-4.4$
- Login into the compute node from the login node
ssh gnXX
replace gnXX with the name of the compute node that was allocated to your job.
bash-4.4$ ssh gn03
The output below shows conection to gnXX (gn03).
The authenticity of host 'gn03 (<no hostip for proxy command>)' can't be established.
ECDSA key fingerprint is SHA256:Tso0v66J1JxJ/sgsbP8zAyVWhbfO9BzFsapna1tHFrc.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'gn03' (ECDSA) to the list of known hosts.
[user@gn03 ~]$
Run Marimo Notebook
Marimo supports 2 ways of work:
- Project notebooks: Notebooks are part of a project's environment, usually virtual environment
- Sandbox notebooks: Notebooks are self-contained with isolated dependencies, i.e. code and all Python libraries are part of one Python file thanks to inline metadata.
Project notebooks
Create a Python virtual environment with uv and install Marimo. You can add additional libraries, but it is not necessary, as Marimo will ask and install any missing libraries when you run it.
mkdir marimo_notebooks
cd marimo_notebooks
uv venv
uv pip install marimo
Replace gnXX with assigned GPU node
uv run marimo edit --headless -p 7000 --host gnXX marimo_test.py
You get an access token, like is shown below:
Edit marimo_test.py in your browser 📝
➜ URL: http://gnXX:7000?access_token=<your-access-token>
This token is need to login in on Jupyter Notebook via local browser.
- Open a new tab terminal and tunnel to the node
For Windows users using puTTy:
Add Source Port: 8200
Add Destination: gn03:7000
For Linux and MAC users, use following command:
ssh -N -f -L 8200:gnXX:7000 <you-username>@vglogin0005.vega.izum.si
- Open your browser and enter the address
http://localhost:8200/?token=<your-token>
Sandbox notebooks
Run a Marimo notebook in an isolated, self-contained environment.
Replace gnXX with assigned GPU node:
uvx marimo edit --sandbox --headless -p 7000 --host gnXX marimo_sandbox_test.py
You get an access token:
Edit marimo_test.py in your browser 📝
➜ URL: http://gnXX:7000?access_token=<your-access-token>
- Open a new tab terminal and tunnel to the node
For Windows users using puTTy:
Add Source Port: 8200
Add Destination: gn03:7000
For Linux and MAC users, use following command:
ssh -N -f -L 8200:gnXX:7000 <you-username>@vglogin0005.vega.izum.si
- Open your browser and enter the address
http://localhost:8200/?token=<your-token>
Performance tip
Since your home directory resides on networked disk, performance can be slow. This can be improved by using a scratchdisk. Disadvantage is, that once you log off, everything on temporary scratchdisk is deleted.
Run marimo on a scratchdisk. Note that this can be done after a GPU node has been allocated.
Change directory to the scratchdisk:
cd /scratch/slurm/${SLURM_JOB_ID}
Make sure python bytecody is placed on scratchdisk...
export PYTHONPYCACHEPREFIX="/scratch/slurm/${SLURM_JOB_ID}/pycache"
...and uv is using scratchdisk for caching:
export UV_CACHE_DIR="/scratch/slurm/${SLURM_JOB_ID}/uv-cache"
Replace gnXX with assigned GPU node
uvx marimo edit --sandbox --headless -p 7000 --host gnXX marimo_sandbox_test.py
Reactive notebooks
To make sure that marimo uses reactive execution check if settings in bottom left corner are set to on startup: autorun and on cell change: autorun.