JupyterHub Basics
This page covers the fundamentals you need to work in a UZH JupyterHub deployment — from launching your server to managing files and Python environments.
The JupyterLab interface
JupyterLab is the web-based environment you see after logging in. It provides a file browser, notebook editor, terminal, and more.
Key areas of the UI:
| Area | Description |
|---|---|
| Left sidebar | File browser, running terminals & kernels, table of contents |
| Main work area | Open notebooks, scripts, terminals — arrange in tabs or splits |
| Status bar | Kernel name and status, line/column position |
| Launcher | Opens a new notebook, console, or terminal |
Using Git in JupyterLab
You can use Git directly from the terminal or via the built-in Git extension.
- JupyterLab Git extension docs
- Get started with Git (GitLab) — UZH’s official Git hosting is GitLab
Open a terminal from the Launcher and use standard git commands, or click the Git icon in the left sidebar for a visual interface.
Do not store credentials (or, in fact, anything really secret) on a JupyterHub server. Your team-mates (on a group-server), teachers, IT staff, will all have access to your files as one and the same user,
jovyan. We recommend short-lived github tokens.
Distributing materials with nbgitpuller
nbgitpuller is pre-installed in the standard course images. It lets teachers hand out a single click-to-open link that clones a Git repository into a participant’s home directory — and, on later clicks, merges updates without overwriting the participant’s own changes.
Generate a link with the nbgitpuller link generator:
| Field | What to enter |
|---|---|
| JupyterHub URL | The hub URL you reach once you are logged in (e.g. https://<course>.zi.uzh.ch) — not the OLAT/LMS link |
| Git repository URL | The HTTPS URL of the repository to pull (e.g. a GitLab or GitHub repo) |
| Branch | The branch to pull (optional; defaults to the repo’s default branch) |
| File to open | A notebook or folder to open after pulling (optional) |
Share the generated link with participants. Opening it logs them in (if needed), clones or updates the repository under /home/jovyan, and opens the requested file. See the nbgitpuller documentation for details on the underlying auto-merge behaviour.
👩🎓 Participants: If your teacher sends you an nbgitpuller link (it loads course materials into your home directory), you can simply click it — it logs you in if needed and copies the latest materials for you. Your own changes are preserved.
Python virtual environments and kernels
Each notebook runs against a kernel — a running Python process. The kernels available in the Launcher correspond to Python environments installed on your server.
What survives a server restart — and what doesn’t
| Location | Survives restart? |
|---|---|
Files under /home/jovyan | ✅ Yes — this is a persistent volume |
Packages you install with pip install (they go to ~/.local) | ✅ Yes — ~/.local lives under /home/jovyan |
Virtual environments made with my-venv-kernel | ✅ Yes — saved to your home and restored automatically (how) |
| A virtual environment you created by hand somewhere else | ⚠️ Only if it is under /home/jovyan — and see the warning below |
| The pre-installed base environment itself | ♻️ Reset on restart — it lives in the container image and is rebuilt fresh |
On the UZH course images, pip is configured (via PIP_USER=1) so that pip install <package> installs into your personal ~/.local directory by default. Because ~/.local sits inside your persistent /home/jovyan, those packages survive restarts and are picked up by the base-environment kernel. In other words, pip install is the supported way to persistently extend the pre-configured base environment — you keep all the packages your course already provides and simply add your own on top.
The base environment image layer is still rebuilt fresh on every restart, so you can never permanently break it: if one of your ~/.local packages ever wedges things, removing it (or clearing ~/.local) returns you to a clean base.
When to create a dedicated virtual environment instead
Extending the base environment with pip install is convenient, but everything lands in one shared ~/.local. Create a dedicated virtual environment when you want:
- isolation — a self-contained set of packages that can’t clash with the base environment or with another project, or
- reproducibility — a clean, separately-registered kernel you can recreate from a
requirements.txt(see Sharing an environment definition).
Creating a custom kernel
Use the bundled my-venv-kernel helper. Open a terminal from the Launcher and run:
my-venv-kernel myenv --create numpy pandas matplotlib # add whatever packages you need
This creates a virtual environment, installs the packages you list (plus ipykernel), and registers a kernel named Python (myenv). Refresh the Launcher (or reload the page) — the new kernel will appear as an option.
Every command has the same shape: the environment name first, then what you want done with it.
| Command | What it does |
|---|---|
my-venv-kernel myenv --create numpy pandas | Create the environment and register its kernel |
my-venv-kernel myenv --create -r requirements.txt | … from a requirements file instead |
my-venv-kernel myenv --create --python 3.11 | … on a different Python version |
my-venv-kernel myenv --add scikit-learn | Install more packages into it (and save it) |
my-venv-kernel myenv --save | Save changes you made another way (see below) |
my-venv-kernel myenv --remove | Delete it completely — kernel, environment and saved copy |
my-venv-kernel --help | The authoritative usage, with both package-management models explained |
--createis spelled out on purpose:my-venv-kernel myenvon its own does not create anything, it tells you which operations exist. Creating an environment installs thousands of files, so it is asked for explicitly rather than by omission.
To install packages into a venv you are working in, you can also use %pip install <package> in a notebook running on that kernel, or activate the environment in a terminal. Both work — but they change the environment behind the helper’s back, so save it afterwards with my-venv-kernel myenv --save. You will be reminded: a kernel that starts with unsaved changes prints a warning, and the server saves what it can when it shuts down.
Where your environments live, and what “saved” means
You do not need to manage this — but it explains what you see.
Your home directory is network-attached storage. It is excellent for notebooks and data, and poor for virtual environments: a venv is around 12 000 small files, and every single one costs a network round trip, on every kernel start. Measured on a real server, a venv built directly in the home took five minutes to create and 40 seconds just to import numpy, pandas — every time a notebook started.
So my-venv-kernel keeps the environment itself on fast local disk and stores one compact copy of it in your home. What follows from that:
- A kernel restores its environment automatically the first time you use it after a restart. Expect a few seconds, once, while JupyterLab shows kernel starting.
- Packages added with
--addare saved immediately. - Packages installed any other way (
%pip install, an activated terminal) are saved when the server shuts down, and you are warned at every kernel start until they are.--savemakes it certain. - Use
--removeto delete an environment. It is no longer one directory you canrm -rf.
On deployments whose home is already local disk (the fleet — see Storage), none of this applies: the environment simply lives in ~/my-venvs/<name>. The commands are the same either way.
Building a venv by hand (
python -m venv ~/my-venvs/myenv) still works, but on a network-home deployment it is the slow path described above — minutes to create, and a long pause on every kernel start — and nothing restores or saves it for you. Usemy-venv-kernel.
Sharing an environment definition
To make your environment reproducible, export its package list. In a notebook running your environment’s kernel:
import sys
!{sys.executable} -m pip freeze > requirements.txt
(%pip freeze > requirements.txt does not work — %pip is not a shell, so the > ends up as an argument to pip. !pip is a shell, but it finds the base environment’s pip, not your environment’s.) Or from a terminal:
$(my-venv-kernel myenv --restore) -m pip freeze > requirements.txt
Anyone with that file — including your future self on a new server — can recreate the environment with:
my-venv-kernel myenv --create -r requirements.txt
Big frameworks (PyTorch, CUDA, vLLM): build on the image, never beside it
The course images already contain PyTorch with its CUDA libraries, matched to the GPU nodes and to each other. Check what you have with pip show torch (currently torch 2.14, CUDA 13; the version moves when the image is updated). Almost everything that needs a GPU — transformers, vllm, bitsandbytes, peft — only has to be installed on top of that copy:
pip install vllm # no version: pip picks the newest vLLM built for the image's torch
pip can do that because the images hold their torch and CUDA versions fixed for every pip install, yours included (PIP_CONSTRAINT). A package that insists on a different torch then fails to install with ResolutionImpossible instead of breaking your kernel later. That error is the protection working: pick a version of the package that fits the image’s torch (usually the newest one), don’t work around it.
On top of the image, vLLM adds about 4 GB and 50 000 files to ~/.local: it brings CUDA compiler and kernel libraries of its own, which is expected and fine. That is far less than a second PyTorch, but on the fleet it is still copied at every start (see below). If the whole course needs vLLM, the better place for it is the course image — teachers can ask ZI to add it there.
Courses with the AI assistant enabled: vLLM installs a newer
mcplibrary than the assistant supports, and the copy in~/.localtakes precedence, so the assistant may stop working afterpip install vllm. In courses where the assistant is not enabled (the default) this has no effect.
Three ways around the protection cause most of the trouble we see. Avoid them:
| Don’t | What goes wrong | Do instead |
|---|---|---|
Force a second torch into ~/.local (pip install --force-reinstall torch, pip install --isolated ..., or pip run with PIP_CONSTRAINT unset). Plain pip install torch or --upgrade torch is harmless: it keeps the image’s version. Many homes also still hold a copy from before the images held torch fixed. | A copy in ~/.local is loaded instead of the image’s. If its version differs, imports fail with errors such as undefined symbol: ncclCommResume or libcurand.so... cannot open shared object file, often in a package that has nothing to do with what you installed. Even a copy of the same version is about 5 GB that the fleet copies at every start. | Leave torch to the image. Check for and remove a copy you already have — see below. |
Build a venv with uv, conda or a different Python (uv venv --python 3.12, uv pip install vllm) | These tools do not read pip’s settings, so nothing holds torch fixed: they install a complete second PyTorch + CUDA stack, 8–10 GB and about 100 000 files per environment, usually for an older torch than the image’s. | Install into the base environment with pip, as above. If you really need an isolated environment, use my-venv-kernel <name> --create --cuda ..., which keeps the image’s torch versions. |
Pin an old version from a tutorial (pip install vllm==0.32.0) | Each vLLM release requires one exact torch. An old one needs an old torch, so it either fails to install or, through uv, drags that old torch in. | Install without a version, and let pip choose the one that fits. |
On the fleet, size is the second problem. There your home is copied onto the server at every start and checked for changes every ten minutes (how), so an environment in your home is copied with it. In the LLM course in autumn 2026, typical homes held 20 GB in about 140 000 files, almost all of it two copies of PyTorch, its CUDA libraries and cached model downloads; the participants’ own work was under half a gigabyte. Such a home takes several minutes, up to a quarter of an hour, to start, and on stop the final save can run out of time, so the last changes are lost. Restarting does not help: every start copies everything again.
Keep environments small, and keep the big parts in the image:
- Never a second PyTorch. Install add-ons with plain
pip installas shown above. - Model downloads go to
~/.cache/huggingfaceon the fleet, which is in your home. Delete models you no longer need, and ask your teacher whether the course provides them pre-downloaded (Plan for large models). - One environment per need. A venv you no longer use is still copied at every start. Remove it with
my-venv-kernel <name> --remove, or delete its folder.
Is my home affected, and how do I clean it up?
In a terminal, see what takes the space:
du -sh ~/.local ~/.cache ~/my-venvs ~/*/ 2>/dev/null | sort -h | tail
Then check whether ~/.local holds packages that the image itself provides — torch, triton and the CUDA libraries torch is built against. The image lists them in /opt/constraints.txt, so this command prints exactly the packages in your ~/.local that shadow one of the image’s:
pip list --user --format=freeze | cut -d= -f1 | tr 'A-Z_.' 'a-z--' | grep -xFf <(sed -E 's/[<>=!~;[ ].*//' /opt/constraints.txt | tr 'A-Z_.' 'a-z--')
It should print nothing. If it lists packages (often torch, triton and nvidia-* libraries left over from before the images held torch fixed), remove exactly those, then restart the kernel:
pip list --user --format=freeze | cut -d= -f1 | tr 'A-Z_.' 'a-z--' | grep -xFf <(sed -E 's/[<>=!~;[ ].*//' /opt/constraints.txt | tr 'A-Z_.' 'a-z--') | xargs -r pip uninstall -y
Packages vLLM installed for itself (such as nvidia-cutlass-dsl or nvidia-cuda-nvcc) are not on that list and stay. A venv you built with uv or by hand — for example a folder holding bin/python and pyvenv.cfg — can be removed with rm -rf <folder> once you no longer need it. Re-install vLLM with plain pip install vllm instead.
After an image update the image’s torch can move to a new version. An add-on that was built for the old one (vLLM in particular) then stops importing. Run
pip install --upgrade vllmonce: pip again picks the version that fits. If it reportsResolutionImpossible, no vLLM release for the new torch exists yet — tell your teacher rather than installing an older torch.
👩🎓 Participants: Course environments are pre-configured by your teacher. To add an extra package,
pip install <package>is usually enough — on the course images it installs into your persistent~/.localand extends the base environment (see What survives a restart). Create a dedicated virtual environment (as shown above) when you need an isolated, reproducible setup.
👩🏫 Owners / Coaches: Pre-installed kernels are baked into the server Docker image, which is built and deployed by ZI. To add a kernel or package for the whole course, contact ZI so it can be added to the course image. You can also provide a
requirements.txtto participants so they can recreate the exact environment in their own server.
UZH persistent volumes
Each JupyterHub deployment provides two persistent storage areas:
/home/jovyan— your personal home directory. Notebooks, data files and your saved virtual environments survive server restarts./home/jovyan/shared— a read-only directory (symbolic link to/home/shared) shared with the whole course.
Both volumes are backed by Azure Blob Storage over NFS, which means they are network-attached and not limited by the number of disks a virtual machine can hold. This allows many students to run concurrently on the same node.
The description above is that of an isolated deployment, where the home is mounted live. On a fleet deployment your home still persists, but by a different mechanism — it is copied in when the server starts and copied back about every ten minutes, and the shared materials sit at
/srv/sharedrather than/home/shared. That difference changes what happens on a crash and how quickly a server starts, so if your course is on the fleet see Storage.
Key points:
/home/jovyan— your personal persistent directory. Files here are not lost when your server stops. Each user’s data is stored in a separate subdirectory on the shared volume, isolated by username. It is private — other participants cannot see it./home/jovyan/shared— read-only course materials provided by your teacher. It is not a place to exchange files with classmates: you cannot write to it./tmp— temporary storage, cleared on restart. Do not store important work here.
Sharing files within a team? The
shareddirectory is read-only and only your teacher can put files there, so it cannot be used to exchange files with team-mates. To work on the same files together, your team needs a collaboration group server, where all group members share one home directory — either choose the same group under My Group if your course opened self-service, or ask your teacher to assign you. See Roles, Groups & Collaboration.
👩🎓 Participants: Always save your work under
/home/jovyan. If you need to download large datasets temporarily, use/tmpto avoid filling your home directory. If you run out of space, contact your course administrator.To bring your own files in, drag them from your computer onto the file browser in the left sidebar of JupyterLab (or use its upload button). They are stored under
/home/jovyanand survive restarts.
👩🏫 Owners / Coaches: User home directories are served by a single shared Blob NFS PersistentVolumeClaim (
blob-homes-pvc) with per-user subdirectories. There is no per-user storage quota at the Kubernetes level — monitoring storage usage should be done at the Azure storage account level.Writing to the shared volume (
/home/shared) is possible by uploading to the shared-materials container (jupyterhub) in the Azure storage account — this is a different container from the one holding user home directories (jupyterhub-homes). A usage guide for this will be provided to you by ZI.