Installing CUDA toolkit and NVIDIA drivers in a Container

I’ve created an Ubuntu Noble LXC Container and have passed through my NVIDIA GPU, and I’m looking to install the CUDA toolkit and NVIDIA driver files to support compilation and nvidia-smi usage. I’ve tried this a few ways but keep hitting complications as I can’t seem to get an exact version match between the host system’s driver version (570.172.08, I’m on CE 25.10.5) and what I can get from apt (570.211.x). I seem to have gotten this working at one point in another container, but can’t seem to retrace my steps. Can anyone point me in the right direction here?

Update, for anyone else struggling with this - was able to get new NVIDIA drivers installed in the LXC using this 570.172.08 driver and running

./NVIDIA-Linux-x86_64-570.172.08.run –no-kernel-module

And was able to install the CUDA libraries from here. Solved!

For the driver you could also have manually edited the incus config file and add one line that passes the hosts nvidia driver to the lxc, that’s what I did. I then only had to manually install the toolkit following the instructions from the Nvidia website

Well that does sound significantly easier! Would you mind sharing the details of how to do that? I haven’t seen that published anywhere (or at least it didn’t come up in any of my searching)

This option only works with the incus backend in 25.10, not with the newer one form the 26 beta.

you basically have to use the shell and

sudo incus config edit name-of-your-lxc

and add these two lines

nvidia.driver.capabilities: compute,graphics,utility,video
nvidia.runtime: "true"

it should look like this:

architecture: x86_64
config:
  boot.autostart: "false"
  image.architecture: amd64
  image.description: Debian trixie amd64 (20251007_05:24)
  image.os: Debian
  image.release: trixie
  image.serial: "20251007_05:24"
  image.type: squashfs
  image.variant: default
  nvidia.driver.capabilities: compute,graphics,utility,video # <- here
  nvidia.runtime: "true" #<- here
  raw.idmap: |-
    uid 568 568
    gid 568 568
  security.privileged: "false"
  user.autostart: "true"

save, exit and restart your lxc and the hosts driver are now available inside the lxc

Edit: i
it was discribed in this post when incus was first introduced

and of course the incus documentation

1 Like

oh and i forgot another thing, which i already explained in another post so i’ll link to it