Container and NVIDIA

What I want to do: run LM Studio Bionic with GPU offload on Ubuntu (25.10) running in Truenas (25.10.6) container with Nvidia graphic card (RTX 2000 ADA). Currently LM Studio Bionic does not see any GPU.

I got nvidia drivers installed in Apps->Settings, on Truenas host, nvidia-smi is able to see my card.

In the Ubuntu, when I try do install drivers, I got following errors:

Setting up linux-modules-nvidia-595-server-6.17.0-41-generic (6.17.0-41.41) ...
linux-image-nvidia-6.17.0-41-generic: constructing .ko files
/usr/bin/ld.bfd: cannot open linker script file /usr/src/linux-headers-6.17.0-41-generic/scripts/module.lds: No such file or directory
/usr/bin/ld.bfd: cannot open linker script file /usr/src/linux-headers-6.17.0-41-generic/scripts/module.lds: No such file or directory
/usr/bin/ld.bfd: cannot open linker script file /usr/src/linux-headers-6.17.0-41-generic/scripts/module.lds: No such file or directory
/usr/bin/ld.bfd: cannot open linker script file /usr/src/linux-headers-6.17.0-41-generic/scripts/module.lds: No such file or directory
/usr/bin/ld.bfd: cannot open linker script file /usr/src/linux-headers-6.17.0-41-generic/scripts/module.lds: No such file or directory
sha256sum: nvidia-drm.ko: No such file or directory
nvidia-drm.ko: FAILED open or read
sha256sum: nvidia-modeset.ko: No such file or directory
nvidia-modeset.ko: FAILED open or read
sha256sum: nvidia-peermem.ko: No such file or directory
nvidia-peermem.ko: FAILED open or read
sha256sum: nvidia-uvm.ko: No such file or directory
nvidia-uvm.ko: FAILED open or read
sha256sum: nvidia.ko: No such file or directory
nvidia.ko: FAILED open or read
sha256sum: WARNING: 5 listed files could not be read
dpkg: error processing package linux-modules-nvidia-595-server-6.17.0-41-generic (--configure):
installed linux-modules-nvidia-595-server-6.17.0-41-generic package post-installation script subprocess returned error exit status 1
dmesg: read kernel buffer failed: Operation not permitted
dpkg: dependency problems prevent configuration of linux-modules-nvidia-595-server-generic:
linux-modules-nvidia-595-server-generic depends on linux-modules-nvidia-595-server-6.17.0-41-generic (= 6.17.0-41.41); however:
Package linux-modules-nvidia-595-server-6.17.0-41-generic is not configured yet.

dpkg: error processing package linux-modules-nvidia-595-server-generic (--configure):
dependency problems - leaving unconfigured

aaand nvidia-smi in container says:

NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

What am I doing wrong?

Im not home right now but in 30 minute I can post my notes on how to set it up for an incus lxc

Ok so basically with incus you don’t have to install the drivers inside the lxc, you pass through the host drivers you already installed to the lxc.
You have to use the shell and

incus config edit yourcontainername

to open the config file for your lxc and add nvidia specific incus config lines.

you have to add these 2 lines to the config file:

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 the changes and restart your lxc.

now if you use nvidia-smi it should work.

If you want to use your gpu for docker you may have to fix the device mounting because incus mounts it as a described in this post :

Thanks. I updated to 27 in the meantime which makes it out-of-the bockish, but has another problems :stuck_out_tongue: