Prerequisites
Push the driver run-file into the LXC
From the Proxmox host shell:
pct push <lxc id> <path/to/source/file> <path/to/target/file>
pct push 100 ./NVIDIA-Linux-x86_64-580.65.06.run ./NVIDIA-Linux-x86_64-580.65.06.run
Enter into the LXC:
pct enter 100
Find the file and make the run-file executable
chmod +x NVIDIA-Linux-x86_64-580.65.06.run
Uninstall any previous drivers
If you already have a driver installed, this can be uninstalled using the uninstall script that was included in the installation:
/usr/bin/nvidia-uninstall
It will complain about not finding the kernel modules, but since this is an LXC these kernel modules are located on the host (Proxmox) and not in the guest (LXC), so this is fine.
Install the driver
Install using the run-file, but skip the kernel modules:
./NVIDIA-Linux-x86_64-580.65.06.run --no-kernel-module
Mount the GPU device into the LXC
external reference: Using an Nvidia GPU with Proxmox LXC
On the Proxmox host, identify the device IDs:
ls -al /dev/nvidia*
It should return something like this:
# ls -al /dev/nvidia*
crw-rw-rw- 1 root root 195, 0 Aug 4 11:19 /dev/nvidia0
crw-rw-rw- 1 root root 195, 255 Aug 4 11:19 /dev/nvidiactl
crw-rw-rw- 1 root root 195, 254 Aug 4 11:19 /dev/nvidia-modeset
crw-rw-rw- 1 root root 234, 0 Aug 5 14:49 /dev/nvidia-uvm
crw-rw-rw- 1 root root 234, 1 Aug 5 14:49 /dev/nvidia-uvm-tools
The device Ids are in columns 5, so 195 and 234 for the devices under /dev/. Add or update these ids into the unprivileged LXC config. Using the nano editor here:
nano /etc/pve/lxc/<lxc id>.conf
Allow access to the device ids:
lxc.cgroup2.devices.allow: c 195:* rw
lxc.cgroup2.devices.allow: c 234:* rw
Then mount the corresponding device paths into the LXC in the same config file:
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-modeset dev/nvidia-modeset 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/nvram dev/nvram none bind,optional,create=file
Save the config, reboot the LXC and verify that the GPU is available by running nvidia-smi
