Last active
July 31, 2026 02:03
-
-
Save 4piu/112dacab274649f8a4be6e4bfb06b27f to your computer and use it in GitHub Desktop.
Access Nvidia GPU on host from unprivileged LXC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # NVIDIA GPU passthrough | |
| # These needs to be put before including common.conf ¯\_(ツ)_/¯ | |
| lxc.cgroup2.devices.allow = c 195:* rwm | |
| lxc.cgroup2.devices.allow = c 509:* rwm | |
| lxc.cgroup2.devices.allow = c 236:* rwm | |
| lxc.mount.entry = /dev/nvidia0 dev/nvidia0 none bind,optional,create=file | |
| # in case you have another GPU | |
| lxc.mount.entry = /dev/nvidia1 dev/nvidia1 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-uvm-tools dev/nvidia-uvm-tools none bind,optional,create=file | |
| lxc.mount.entry = /dev/nvidia-caps dev/nvidia-caps none bind,optional,create=dir | |
| # Distribution configuration | |
| lxc.include = /usr/share/lxc/config/common.conf | |
| lxc.include = /usr/share/lxc/config/userns.conf | |
| lxc.arch = linux64 | |
| # Container specific configuration | |
| lxc.idmap = u 0 100000 65536 | |
| lxc.idmap = g 0 100000 65536 | |
| lxc.rootfs.path = dir:/var/lib/lxc/ubuntu-noble/rootfs | |
| lxc.uts.name = ubuntu-noble | |
| # Network configuration | |
| lxc.net.0.type = veth | |
| lxc.net.0.link = lxcbr0 | |
| lxc.net.0.flags = up | |
| lxc.net.0.hwaddr = 10:66:6a:2a:20:0c |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install the driver in lxc by running
.runinstaller file with--no-kernel-modulesoption. Recommended to match the host driver version.