[SOLVED] Can't get Nvidia GPU passthrough to work on LXC

Then once you add those lines to the CT's config (either manually or via my script) and restart the CT nvidia-smi should just magically work inside
Bash:
echo "lxc.hook.pre-start: sh -c '[ ! -f /dev/nvidia0 ] && /usr/bin/nvidia-modprobe -c0 -u'"
echo "lxc.environment: NVIDIA_VISIBLE_DEVICES=all"
echo "lxc.environment: NVIDIA_DRIVER_CAPABILITIES=all"
echo "lxc.hook.mount: /usr/share/lxc/hooks/nvidia"
 
omg it actually works now :D
is there anything i need to do now for the jellyfin docker container to be able to use the GPU or is it done? :)
 
i just installed the toolkit thing on the CT and tested it with the command on the guide on how to install it. the nvidia-smi found the driver and the gpu so it seemed to work :)

now, im a little confused tho. am i supposed to just copy paste the following into my jellyfin docker-compose.yml?
YAML:
services:
  test:
    image: nvidia/cuda:12.9.0-base-ubuntu22.04
    command: nvidia-smi
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [gpu]

edit:

i decided to put the following part in the jellyfin docker compose file but it didnt really work:
YAML:
    command: nvidia-smi

    deploy:

      resources:

        reservations:

          devices:

            - driver: nvidia

              count: 1

              capabilities: [gpu]
 
Last edited:
thank you SO much for holding my hand through this all. i never could've done it by myself :)
i think it works now. i can view a movie in 4K on jellyfin without the CPU usage shooting to 90%! :D
 
  • Like
Reactions: Impact
i just have one more question before i close this thread; is it possible to add a GPU to two containers at the same time? so for example i can have my media container using the GPU at the same time my Nextcloud VM uses it? just curious :3
 
One thing that stands out to me is the kernel mismatch.

<span>dkms status</span> shows the NVIDIA module was built for <span>7.0.2-6-pve</span>, but <span>uname -a</span> reports you're currently booted into <span>7.0.12-1-pve</span>. That would explain why <span>modprobe nvidia</span> can't find the module under <span>/lib/modules/7.0.12-1-pve</span>.

I'd check whether the matching headers for the running kernel are installed (<span>pve-headers-$(uname -r)</span>), then rebuild the DKMS module (or reinstall the NVIDIA driver package) so it compiles against the current kernel. After that, verify that <span>dkms status</span> lists <span>7.0.12-1-pve</span>, and <span>modprobe nvidia</span> and <span>nvidia-smi</span> work on the host before trying the LXC passthrough again.

It seems like getting the host driver working first is the key step before touching the container configuration.
 
  • Like
Reactions: fabian69420