Skip to main content
2026-12-02

Research code that survives: a GPU dev container for geospatial ML

Could you recreate a figure from your last paper, today, on a new machine? For most of us the honest answer is “maybe, after a day of fixing installs”. The code is usually fine. What breaks is everything around it: the GDAL version, the CUDA driver, a package that was installed by hand and never written down.

I got tired of solving the same setup problems again for every new project and every new student, so I put the setup into a template. This post explains what it does and how to use it. If you prefer watching, there is a 15-minute video at the end.

The idea in one paragraph

The environment is code. Everything a project needs is described in files that live in the repository: a container image for the heavy system libraries (CUDA, GDAL/PROJ, QGIS), and pyproject.toml plus uv.lock for the Python packages. VS Code opens the project inside that container, on your laptop or on a GPU server over SSH, and CI runs in the same image. If it works for you, it works for your colleague, and it works for you again next year.

What you get

The geoml-devcontainer-template gives you, after one clone and “Reopen in Container”:

  • A GPU-ready image based on the b-data JupyterLab CUDA + QGIS stack: NVIDIA CUDA, GDAL/PROJ, QGIS, GRASS, SAGA and Orfeo Toolbox, plus JupyterLab and a full QGIS desktop in the browser via noVNC.
  • uv for Python dependencies. uv add updates the lock file, uv sync rebuilds the environment exactly.
  • Quality checks that run at the right moment: ruff in the editor, pre-commit on every commit, and ruff, mypy and pytest in GitLab CI.
  • Docs with mkdocs-material, and short make targets for the common tasks (make install, make check, make test, make docs, make env).
Terminal output of the dev container first-time setup
The container finishing its first setup on the lab GPU server.

Getting started

You need VS Code with the Remote-SSH and Dev Containers extensions on your laptop, and Docker with the NVIDIA Container Toolkit on the server. No CUDA toolkit is needed on the host, only the driver.

Then, in a terminal on the server:

git clone https://github.com/IslamAlam/geoml-devcontainer-template.git my_project
cd my_project
rm -rf .git
git init -b main
python3 scripts/rename_project.py my_project --author "Jane Doe" --email jane@example.org
rm scripts/rename_project.py

The rename script replaces the placeholder package name everywhere and fills in the author. Open the folder in VS Code, click Reopen in Container, and wait for the first build. After that, make env is a good sanity check: it prints the Python, GDAL and GPU versions the project actually sees.

Output of make env showing Python, GDAL and the GPU
make env: Python, GDAL and the GPU, from inside the container.

The setup guide walks through every step with screenshots, starting from creating an SSH key. If words like image and container are new, the glossary explains them in plain language.

JupyterLab and QGIS, without installing anything

Because the base image comes with JupyterLab and an Xfce desktop, you can forward a port and open notebooks or QGIS in the browser. For quick map checks this is surprisingly handy: the data stays on the server, and you don’t need QGIS on your laptop.

QGIS desktop running in the browser through noVNC
QGIS from the container, in the browser via noVNC.

A few decisions worth explaining

Heavy libraries in the image, Python in uv.lock. GDAL and CUDA are painful to install with pip and change rarely, so they belong in the image. Python packages change often, so they belong in a lock file that you commit. The rule in our lab: never pip install by hand inside the container. Use uv add, so the change ends up in the repository and everyone gets it.

Pin the base image for papers. The image tag defaults to ltr (the QGIS long-term release), which is fine for everyday work. When you submit a paper, pin a concrete version (--base-tag 3.44.15 in the rename script, or the BASE_TAG build argument) so the environment can’t move under you. The versions page explains how to choose a CUDA and PyTorch combination that matches your server’s driver.

Have a mirror. While I was preparing this, the upstream registry was down for a while. The template’s base image is configurable, and there is a mirror at quay.io/is3mansour/jupyterlab-cuda-qgis-base:ltr for exactly that case.

Catch mistakes early. A warning in the editor costs seconds, a failed CI run costs minutes, and a bug in a published figure costs much more. pre-commit runs ruff and a few file checks on every commit; if it fixes something, you git add and commit again.

pre-commit hooks running on the first commit
The first commit, with the pre-commit hooks doing their job.

The tutorial and the VS Code profile

I gave this as a lab tutorial in two parts. Part one covers the tools around the code: git (also with AI agents), VS Code, zsh and tmux, uv, and experiment tracking. Part two is about dev containers. The slides are online at tutorial.geoml-template.imansour.net.

Many of my colleagues are not software engineers by training, so the tutorial also comes with a shared VS Code Research profile: one import gives you the extensions and settings I use for this kind of work. You can import it from this gist via Profiles → Import Profile. (If profile creation fails, temporarily disable GitHub Copilot Chat; the tutorial page explains the workaround.)

The video

Here is the full walkthrough, from a fresh VS Code to a running container on the GPU server (14:30):

If you start a new project from the template and something is unclear or broken, open an issue or a merge request. That is how it gets better.