[Error] Startup fails with "error executing hook" when GPU support is enabled
- 主要語言
- Go
- 星號
- 13k
- 分支
- 541
- 平均合併
- 20 小時 47 分鐘
- 30 天內合併 PR
- 4
描述
**Describe the bug**
I'm unable to start any distrobox containers with GPU passthrough on a new machine. Using `podman` directly, the GPUs are visible as expected: `podman run --rm --device nvidia.com/gpu=all docker.io/library/ubuntu:24.04 nvidia-smi`.
At a guess, it could be related to using `hardware.nvidia-container-toolkit.device-name-strategy = "uuid";` in the machine config (individual GPUs are assigned to containers by UUID, and index-based assignment is no longer an option). I wouldn't have expected it to be relevant when using the `all` keyword, but it's the main difference I can think of in this machine's GPU setup.
**To Reproduce**
Using the following command to create the container, which has worked as expected on other similar machines I've used it on:
```
distrobox create --image docker.io/library/ubuntu:24.04 --name ubuntu-nvidia --additional-flags "--device nvidia.com/gpu=all"
```
The container is created as normal, but `distrobox enter ubuntu-nvidia` fails with:
```
Error: OCI runtime error: unable to start container "94985c2a6bc31c31a9d7caaa35ad0d33d5e149a02b53ec859481983500ede149": crun: error executing hook `/nix/store/72bp8mb7zzpjifcwasj5wh45ixasmck7-nvidia-container-toolkit-1.17.6-tools/bin/nvidia-cdi-hook` (exit code: 1)
{"msg":"error executing hook `/nix/store/72bp8mb7zzpjifcwasj5wh45ixasmck7-nvidia-container-toolkit-1.17.6-tools/bin/nvidia-cdi-hook` (exit code: 1)","level":"error","time":"2025-05-07T07:45:52.916362Z"}
```
I've also tried `--additional-flags "--gpus all"`, `--additional-flags "--gpus all --device=nvidia.com/gpu=all"` and `--additional-flags "--device nvidia.com/gpu="` with a specific GPU UUID, all with the same behaviour.
Using `distrobox create --nvidia --image docker.io/library/ubuntu:24.04 --name ubuntu-nvidia` does allow the container to start, but it isn't able to see any GPUs - although the docs mention this is for the NVIDIA proprietary drivers, and this machine is using the open source ones (blackwell and newer are only fully supported on the open releases), so that may be expected behaviour.
**Expected behavior**
Container starts as normal, and `nvidia-smi` run from inside the container shows info for all GPUs.
**Logs**
[`distrobox enter ubuntu-nvidia --verbose`](https://github.com/user-attachments/files/20079241/distrobox_verbose.txt)
**Desktop (please complete the following information):**
- `podman version 5.4.1`
- `distrobox: 1.8.1.2`
- NixOS unstable
- Installed via `nixpkgs`
貢獻指南
研究方向
錯誤源自容器啟動期間的 nvidia-cdi-hook。檢查 distrobox 的容器建立和 GPU 直通邏輯,相關程式碼可能位於處理 `--additional-flags` 的指令碼中。檢視詳細記錄以追蹤 hook 執行失敗的原因。與正常運作的設定進行比較,以隔離 NixOS 以 UUID 為基礎的 GPU 裝置策略對 hook 的影響。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- go, nixos, shell
- 領域
- cli, devops
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100