无法在 LXC 容器中运行启用了 NVIDIA GPU 的 Docker 容器

Unable to Run NVIDIA GPU-Enabled Docker Containers Inside an LXC Container

提问人:J J 提问时间:9/6/2023 最后编辑:J J 更新时间:9/6/2023 访问量:270

问:

问题:

我在尝试在 LXC 容器中运行需要 GPU 访问的 Docker 容器时遇到了问题。标准 Docker 容器运行良好,但是当我尝试通过添加 or 来使用 NVIDIA GPU 时,容器无法启动。--gpus=all--runtime=nvidia

我收到的错误消息是:

docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error running hook #0: error running hook: exit status 1, stdout: , stderr: Auto-detected mode as 'legacy'
nvidia-container-cli: mount error: failed to add device rules: unable to find any existing device filters attached to the cgroup: bpf_prog_query(BPF_CGROUP_DEVICE) failed: operation not permitted: unknown.

环境:

  • 安装了 Proxmox 8(基于 Debian 12)和 NVIDIA 驱动程序的裸机(已确认使用nvidia-smi)
  • LXC容器也有NVIDIA驱动程序工作(成功运行)nvidia-smi
  • Nvidia Quadro K420(预算低,因为这是我的测试机器)
  • 驱动程序版本: 470.199.02
  • CUDA 版本:11.4
  • LXC 容器的配置包括 NVIDIA 设备的设备直通。

LXC 配置:

# Allow cgroup access
lxc.cgroup2.devices.allow: c 195:* rwm
lxc.cgroup2.devices.allow: c 235:* rwm
lxc.cgroup2.devices.allow: c 511:* rwm
lxc.cgroup2.devices.allow: c 226:* rwm
lxc.cgroup2.devices.allow: c 239:* rwm
lxc.cgroup2.devices.allow: c 243:* rwm

# Pass through device files
lxc.mount.entry: /dev/nvidia0 dev/nvidia0 none bind,optional,create=file
lxc.mount.entry: /dev/nvidiactl dev/nvidiactl none bind,optional,create=file
lxc.mount.entry: /dev/nvidia-uvm dev/nvidia-uvm none bind,optional,create=file
lxc.mount.entry: /dev/nvidia-modeset dev/nvidia-modeset none bind,optional,create=file
lxc.mount.entry: /dev/nvidia-uvm-tools dev/nvidia-uvm-tools none bind,optional,create=file
lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir

我尝试过什么:

  • 已检查Docker和NVIDIA驱动程序是否已安装并单独工作。
  • 已确保LXC容器在特权模式下运行,并且非GPU Docker容器正常工作

我正在寻找有关如何调试此问题并在 LXC 容器中成功运行启用 GPU 的 Docker 容器的任何指导。

Docker GPU 英伟达 LXC Proxmox

评论


答: 暂无答案