From 60128b12c7539acc9d6bce998e18eb876c9c38d4 Mon Sep 17 00:00:00 2001 From: Jared Baur Date: Thu, 26 Sep 2024 13:53:00 -0700 Subject: [PATCH] Prevent usage of hardware.nvidia-container-toolkit.enable This option is not yet compatible with Jetson devices. --- README.md | 2 ++ modules/default.nix | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5e979be6..ef5fad82 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,8 @@ You can run OCI containers with jetpack-nixos by enabling the following nixos op } ``` +Note that on newer nixpkgs the `virtualisation.{docker,podman}.enableNvidia` option is deprecated in favor of using `hardware.nvidia-container-toolkit.enable` instead. This new option does not work yet with Jetson devices, see [this issue](https://github.com/nixos/nixpkgs/issues/344729). + To run a container with access to nvidia hardware, you must specify a device to passthrough to the container in the [CDI](https://github.com/cncf-tags/container-device-interface/blob/main/SPEC.md#overview) format. By default, there will be a single device setup of the kind diff --git a/modules/default.nix b/modules/default.nix index 04964883..924a0fd4 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -25,8 +25,8 @@ let paths = cfg.firmware.optee.supplicant.plugins; }; - nvidiaDockerActive = with config.virtualisation; docker.enable && (docker.enableNvidia || config.hardware.nvidia-container-toolkit.enable); - nvidiaPodmanActive = with config.virtualisation; podman.enable && (podman.enableNvidia || config.hardware.nvidia-container-toolkit.enable); + nvidiaDockerActive = with config.virtualisation; docker.enable && docker.enableNvidia; + nvidiaPodmanActive = with config.virtualisation; podman.enable && podman.enableNvidia; in { imports = [ @@ -149,6 +149,10 @@ in assertion = nvidiaDockerActive -> lib.versionAtLeast config.virtualisation.docker.package.version "25"; message = "Docker version < 25 does not support CDI"; } + { + assertion = (nvidiaDockerActive || nvidiaPodmanActive) -> (!config.hardware.nvidia-container-toolkit.enable); + message = "hardware.nvidia-container-toolkit.enable does not work with jetson devices (yet), use virtualisation.{docker,podman}.enableNvidia instead"; + } ]; # Use mkOptionDefault so that we prevent conflicting with the priority that