diff --git a/CHANGES.md b/CHANGES.md index 1bc8efcc4..723e8c514 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -15,7 +15,9 @@ [Unreleased](https://github.com/bird-house/birdhouse-deploy/tree/master) (latest) ------------------------------------------------------------------------------------------------------------------ -[//]: # (list changes here, using '-' for each new entry, remove this when items are added) +## Documentation + +- Document how to allow Jupyterlab containers to access GPUs on the host machine [2.18.4](https://github.com/bird-house/birdhouse-deploy/tree/2.18.4) (2025-10-01) ------------------------------------------------------------------------------------------------------------------ diff --git a/birdhouse/components/README.rst b/birdhouse/components/README.rst index 273a97175..89b8dbfb2 100644 --- a/birdhouse/components/README.rst +++ b/birdhouse/components/README.rst @@ -821,6 +821,45 @@ Usage The service is available at ``${BIRDHOUSE_PROXY_SCHEME}://${BIRDHOUSE_FQDN_PUBLIC}/jupyter``. Users are able to log in to Jupyterhub using the same user name and password as Magpie. They will then be able to launch a personal jupyterlab server. +GPU support for jupyterlab containers +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If the host machine has GPUs and you want to make them available to the docker containers running Jupyterlab: + +1. ensure that the GPU drivers on the host machine are up to date +2. install the `NVIDIA container toolkit`_ package on the host machine +3. `configure docker`_ to use the NVIDIA as a container run-time +4. restart docker for the changes to take effect +5. add the following to the ``JUPYTERHUB_CONFIG_OVERRIDE`` variable in your local environment file: + +.. code-block:: python + + # enable GPU support + import docker + + c.DockerSpawner.extra_host_config["device_requests"] = [ + docker.types.DeviceRequest(count=-1, capabilities=[["gpu"]]) + ] + + +This will allow the docker containers to access all GPUs on the host machine. To limit the number of GPUs you want to make available +you can change the ``count`` value to a positive integer or you can specify the ``device_ids`` key instead. ``device_ids`` takes a list +of integers representing the devices (GPUs) that you want to enable. Device IDs for each GPU can be inspected by running the ``nvidia-smi`` +command on the host machine. + +The `driver capabilities`_ setting indicates that this device request is for GPUs (as opposed to other devices that may be +available such as TPUs). + +For example, if I only want to make available GPUs with ids 1 and 4 you would set: + +.. code-block:: + + docker.types.DeviceRequest(device_ids=[1, 4], capabilities=[["gpu"]]) + +.. _NVIDIA container toolkit: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html +.. _configure docker: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#configuring-docker +.. _driver capabilities: https://docs.docker.com/reference/compose-file/deploy/#capabilities + How to Enable the Component ---------------------------