Conversation
Bind-mount /etc/nvidia-container-runtime/host-files-for-container.d (read-only) into the gateway container when it exists, so the nvidia runtime running inside k3s can apply the same host-file injection config as on the host — required for Jetson/Tegra platforms. Signed-off-by: Evan Lezar <elezar@nvidia.com>
Use ghcr.io/nvidia/k8s-device-plugin:2ab68c16 which includes support for mounting /etc/nvidia-container-runtime/host-files-for-container.d into the device plugin pod, required for correct CDI spec generation on Tegra-based systems. Also included is an nvcdi API bump that ensures that additional GIDs are included in the generated CDI spec. Signed-off-by: Evan Lezar <elezar@nvidia.com>
initgroups(3) replaces all supplemental groups with the user's entries from /etc/group, discarding GIDs injected by the container runtime via CDI (e.g. GID 44/video needed for /dev/nvmap on Tegra). Snapshot the container-level GIDs before initgroups runs and merge them back afterwards, excluding GID 0 (root) to avoid privilege retention. Signed-off-by: Evan Lezar <elezar@nvidia.com>
On Jetson/Tegra platforms nvidia-smi is installed at /usr/sbin/nvidia-smi rather than /usr/bin/nvidia-smi and may not be on PATH inside the sandbox. Fall back to the full path when the bare command is not found. Signed-off-by: Evan Lezar <elezar@nvidia.com>
|
cc @johnnynunez |
|
LGTM @elezar |
Yes, i know. I was tracking it. And tested |
|
I dug into the GID-preservation change here and I think PR #710 may make it unnecessary. What I verified locally:
If that holds generally, then once #710 adds the needed GPU device paths to So I think we should re-check whether the |
|
Follow-up: I removed the checked-in custom If someone still needs that image on a live gateway for testing, they can patch the running cluster in place: openshell doctor exec -- kubectl -n kube-system patch helmchart nvidia-device-plugin --type merge -p '{
"spec": {
"valuesContent": "image:\n repository: ghcr.io/nvidia/k8s-device-plugin\n tag: \"2ab68c16\"\nruntimeClassName: nvidia\ndeviceListStrategy: cdi-cri\ndeviceIDStrategy: index\ncdi:\n nvidiaHookPath: /usr/bin/nvidia-cdi-hook\nnvidiaDriverRoot: \"/\"\ngfd:\n enabled: false\nnfd:\n enabled: false\naffinity: null\n"
}
}'
openshell doctor exec -- kubectl -n nvidia-device-plugin rollout status ds/nvidia-device-plugin
openshell doctor exec -- kubectl -n nvidia-device-plugin get ds nvidia-device-plugin -o jsonpath='{.spec.template.spec.containers[0].image}{"\\n"}'That only affects the running gateway. Recreating the gateway reapplies the checked-in manifest. |
|
Once the #710 is reviewed and merged, I will add it to here and test it again. I'm getting a lease on colossus for a Jetson-based system. It's very likely there will be some updates to the policy required, with the #677 now merged and before that, in many contexts landlock policies were not correctly applied. |
| const HOST_FILES_DIR: &str = "/etc/nvidia-container-runtime/host-files-for-container.d"; | ||
| if std::path::Path::new(HOST_FILES_DIR).is_dir() { | ||
| let mut binds = host_config.binds.take().unwrap_or_default(); | ||
| binds.push(format!("{HOST_FILES_DIR}:{HOST_FILES_DIR}:ro")); | ||
| host_config.binds = Some(binds); | ||
| } |
There was a problem hiding this comment.
For the context, without this mount the failure is:
The error says: CDI --device-list-strategy options are only supported on NVML-based systems — the device plugin can't detect the GPU via NVML (since Tegra uses a different driver model), so it refuses to start with CDI mode.
The bind mount is needed. Without it, the NVIDIA toolkit inside the gateway can't recognize this as a Tegra platform with GPU capabilities, CDI spec generation fails, and the device plugin crashes.
- Bump nvidia-container-toolkit from 1.18.2 to 1.19.0 to support the -host-cuda-version flag used by newer CDI spec generation. - Replace local filesystem check for host-files-for-container.d with Docker API kernel version detection (contains "tegra"). This fixes remote SSH deploys where the CLI machine may not have the directory. - Only perform the Tegra check when GPU devices are requested.
Testing on Jetson Thor (NVIDIA Thor GPU, driver 580.00, CUDA 13.0)Validated the following on a physical Jetson Thor device: Container Toolkit bump (1.18.2 → 1.19.0)
|
…ID preservation - Log when Tegra platform is detected and host-files bind mount is added, including the kernel version from the Docker daemon. - Extract CDI GID snapshot logic into `snapshot_cdi_gids()` function that only activates when GPU devices are present (/dev/nvidiactl exists). - Log preserved CDI-injected GIDs when they are restored after initgroups. - Fix cargo fmt formatting issue in docker.rs.
Summary
Adds GPU support for NVIDIA Tegra/Jetson platforms by bind-mounting the
host-files configuration directory, updating the device plugin image, and
preserving CDI-injected GIDs across privilege drop.
Related Issue
Part of #398 (CDI injection). Depends on #568 (Tegra system support). Should be merged after #495 and #503.
Upstream PRs:
Changes
/etc/nvidia-container-runtime/host-files-for-container.d(read-only) into the gateway container when present, so the nvidia runtime inside k3s applies the same host-file injection config as the host — required for Jetson/Tegra CDI spec generationadditionalGidsin the CDI spec (GID 44 /video, required for/dev/nvmapaccess on Tegra)initgroups()during privilege drop, so exec'd processes retain access to GPU devices/usr/sbin/nvidia-smiin the GPU e2e test for Tegra systems wherenvidia-smiis not on the defaultPATHTesting
mise run pre-commitpassesChecklist