Making NVIDIA Drivers Available to LXC Containers on Proxmox Boot
I have a proxmox instance that’s running Ollama inside an unprivileged LXC container with GPU passthrough. It’s set up the same way you would pass a GPU to a plex or jellyfin container.
I use this machine only as a local LLM server. To save power when I’m not using it, I’ve configured it to shut down automatically in the evening. The problem was, when I turned the server back on, the LXC container couldn’t communicate with the Nvidia driver.
When I ran nvidia-smi
inside the LXC container, I encountered the following error: nvidia-smi has failed because it couldn't communicate with the NVIDIA driver.
As far as I understand proxmox wasn’t loading the Nvidia driver on boot. My solution was to just run nvidia-smi
on the host after boot which could be achieved by adding a one-liner to the crontab:
Open the crontab for editing: crontab -e
.
Add the following line at the end:
@reboot /usr/bin/nvidia-smi > /dev/null 2>&1
This will call nvidia-smi
on reboot and discard the output. Ensure the path to nvidia-smi is correct and accessible to the user editing the crontab.
The final step is to add a startup delay for the container that utilizes the Nvidia driver. This ensures the container starts only after the host has successfully loaded the Nvidia driver.