Admins will be upgrading ORNL GitLab Servers on Saturday, 16 May 2026, from 7 AM until 11 AM EST. Repositories will experience intermittent outages during this time.
To use Nvidia GPU in the cluster the nvidia-container-runtime and runc are needed. To get the two components it suffices to add the following to the configuration
> Note: this article assumes `services.k3s.enable = true;` is already set
## Enable the Nvidia driver
```
virtualisation.docker = {
enable = true;
enableNvidia = true;
hardware.nvidia = {
open = true;
package = config.boot.kernelPackages.nvidiaPackages.stable; # change to match your kernel
nvidiaSettings = true;
};
# Hack for getting the nvidia driver recognized
services.xserver = {
enable = false;
videoDrivers = [ "nvidia" ];
};
environment.systemPackages = with pkgs; [ docker runc ];
Note, using docker here is a workaround, it will install nvidia-container-runtime and that will cause it to be accessible via /run/current-system/sw/bin/nvidia-container-runtime, currently its not directly accessible in nixpkgs.
## Configure k3s
You now need to create a new file in `/var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl` with the following
@@ -22,15 +68,8 @@ You now need to create a new file in `/var/lib/rancher/k3s/agent/etc/containerd/
Update: As of 12/03/2024 It appears that the last two lines above are added by default, and if the two lines are present (as shown above) it will refuse to start the server. You will need to remove the two lines from that point onward.
Note here we are pointing the nvidia runtime to "/run/current-system/sw/bin/nvidia-container-runtime".
Now apply the following runtime class to k3s cluster:
```yaml
@@ -43,16 +82,175 @@ metadata:
name:nvidia
```
Following [k8s-device-plugin](https://github.com/NVIDIA/k8s-device-plugin#deployment-via-helm) install the helm chart with `runtimeClassName: nvidia` set. In order to passthrough the nvidia card into the container, your deployments spec must contain
Restart k3s:
```yaml
```
systemctl restart k3s.service
```
Ensure that the Nvidia runtime is detected by k3s:
If successful, the output will look like the following:
```
Thu Sep 25 04:17:42 2025
to test its working exec onto a pod and run nvidia-smi. For more configurability of nvidia related matters in k3s look in [k3s-docs](https://docs.k3s.io/advanced#nvidia-container-runtime-support).