Jupyter Notebook

Euler Cluster

This service is made for developing and debugging your code, not to run your code on the cluster. If you wish to run it, please use the SLURM queue system. Please only request multiple cores if you are planning to run some code that can make use of multiple cores.

For more information go to the following website:

~/.config/euler/jupyterhub

I want to load a cluster module / I want to activate a virtualenv / Jupyterlab is missing some features

This script will be sourced (. ~/.config/euler/jupyterhub/jupyterlabrc) before starting any service.

cat << EOF > ~/.config/euler/jupyterhub/jupyterlabrc
module load stack
module load python_cuda
#module load sage
#jupyter kernelspec install --user $SAGE_EULER_ROOT/share/jupyter/kernels
EOF

Compute Clients (ada-X) and Linux Desktops

First you need to create a new uv project and install jupyter into it:

export UV_CACHE_DIR=/scratch/userdata/${USER}/CACHE
export UV_NO_CACHE=1
cd /scratch/userdata/${USER}

# uv will create a virtual env for each project
uv init new-uv-project

Now add packages to the new project, the packages will be installed inside a virtual environment:

cd new-uv-project

# when inside the project uv will recognize and use the virtual env
uv add notebook

To run jupyter you can use the following:

uv run --with jupyter jupyter lab --no-browser

Port forwarding setup for Compute Clients

If you like to run it on our “central clients” (ada-X) you need to do a port forwarding, to have access to the notebook.

There are some requirements:

The following command will start a new jupyter notebook and open a ssh tunnel.

You need to modify the following in the command:

  • HOST="ada-10" with the host you like
  • USERNAME="username" with your username to connect.

The list of hosts you can use is on the following page:

HOST="ada-22"; USERNAME="${USER}"; PORT=$(($RANDOM % 1000 + 8000)); ssh -t $USERNAME@$HOST -L $PORT:localhost:$PORT "screen cd /scratch/userdata/${USER}/new-uv-project; uv run --with jupyter jupyter lab --no-browser --port $PORT"

You need to keep the terminal window running otherwise the port forwarding will stop. The notebook however will still be running on the “central client”, you will just loose the connection in to the webinterface.


To be able to connect to it again, it get’s a bit tricky, you need to know on which port you have started the notebook and reopen a port forwarding to it.

This can be done with the following command (you need to modify HOST=, USERNAME= and PORT=):

HOST="ada-22"; USERNAME="username"; PORT=8943; ssh $USERNAME@$HOST -L $PORT:localhost:$PORT

Posted on
in Computing

PROTECT YOUR BRAINWORK.

An IT Security Initiative
https://itsecurity.ethz.ch

Trending

Categories

Recent Posts