Set runtimeClassName for GPU-enabled images

Hi!

I’m using k3s to set up a Kubernetes cluster with JupyterHub to run on a GPU-enabled server. However, when I spin up an image, I don’t get any GPU devices, nor does nvidia-smi work.

When running the example code on the JupyterHub docs, the GPU is schedulable and when deploying my own pod, I can run nvidia-smi just fine. The thing is that k3s requires the runtimeClassName to be set, which is not the case for the Jupyter-launched pods. Is there a way to enable this?

You should be able to set extra parameters using KubeSpawner.extra_pod_config:
https://jupyterhub-kubespawner.readthedocs.io/en/6.0.0/spawner.html#kubespawner.KubeSpawner.extra_pod_config

1 Like

Oh I didn’t think about modifying the Spawner itself, thank you for the tip!

I guess I would use this setting then in my config?

Yes. You could also use hub.config

1 Like

This two changes allowed JupyterHub to work with k3s.

hub:
  revisionHistoryLimit:
  config:
    KubeSpawner:
      extra_pod_config:
        runtimeClassName: nvidia
singleuser:
  extraResource:
    limits:
     nvidia.com/gpu: 1