Getting an NVIDIA graphics card to pass through into an unprivileged Proxmox LXC container can be tricky due to missing device nodes, varying cgroup numbers, and unprivileged user namespace permissions.
This short guide summarizes the final working solution.
Step 1: Install the Driver on the Host
- Install the official NVIDIA driver on your Proxmox host (download the latest production version from the NVIDIA Unix Drivers page). Make the installer executable with
chmod +xand run it via./.
Step 2: Install User-Space Utilities in the Container
To use nvidia-smi and talk to the host’s GPU driver without conflicting with its kernel modules, you must install the user-space portion inside your LXC container:
- Download the exact same NVIDIA driver version matching your host from the NVIDIA Unix Drivers page.
- Make the installer executable:
chmod +x NVIDIA-Linux-x86_64-*.run
- Run the installer using the
--no-kernel-moduleflag:
./NVIDIA-Linux-x86_64-*.run --no-kernel-module
- This ensures it only installs
nvidia-smiand user-space libraries, leaving the kernel module management entirely to the Proxmox host.
Step 3: Check Your Host Cgroup Numbers
Before editing your container, run this command on your Proxmox host to verify the major numbers for your specific devices:
ls -l /dev/nvidia* /dev/dri/* 2>/dev/null
- Look at the number before the comma (e.g.,
226,507,195). Ensure the major numbers in the next step match what your host outputs.
Step 4: Configure the Container (/etc/pve/lxc/100.conf)
Open your container configuration file on the host (nano /etc/pve/lxc/100.conf) and add the required cgroup device allowances along with the explicit bind mounts.
Using the optional, create=file, and mode=0666 flags ensures that:
- The container won’t crash on boot if the host driver isn’t fully initialized yet.
- Unprivileged containers can bypass permission locks by making the files globally readable/writable (
0666) inside the container.
Add these lines to your container configuration file (replacing 100 with your actual container ID):
# Cgroup permissions (adjust major numbers if yours differ)
lxc.cgroup2.devices.allow: c 226:* rwm
lxc.cgroup2.devices.allow: c 507:* rwm
lxc.cgroup2.devices.allow: c 195:* rwm
# Mount entries with mode=0666 override permissions inside unprivileged containers
lxc.mount.entry: /dev/nvidia0 dev/nvidia0 none bind,optional,create=file,mode=0666
lxc.mount.entry: /dev/nvidiactl dev/nvidiactl none bind,optional,create=file,mode=0666
lxc.mount.entry: /dev/nvidia-modeset dev/nvidia-modeset none bind,optional,create=file,mode=0666
lxc.mount.entry: /dev/nvidia-uvm dev/nvidia-uvm none bind,optional,create=file,mode=0666
lxc.mount.entry: /dev/nvidia-uvm-tools dev/nvidia-uvm-tools none bind,optional,create=file,mode=0666
lxc.mount.entry: /dev/dri/card0 dev/dri/card0 none bind,optional,create=file,mode=0666
lxc.mount.entry: /dev/dri/renderD129 dev/dri/renderD129 none bind,optional,create=file,mode=0666
Step 5: Restart the Container
Apply the changes by performing a full stop and start cycle from the Proxmox host:
pct stop 100
pct start 100
Step 6: Verify Inside the Container
Jump into your container to confirm everything is communicating properly:
pct enter 100
nvidia-smi
Congratulations! You should now be able to fully use your GPU within your LXC container. Enjoy.