Install and config NVIDIA drivers on Proxmox VE host and enable GPU usage in LXC containers.
Before we begin, I want to thank my colleague @juanlu13 for providing the original source on which this manual is based.
In this guide, we will install the Nvidia drivers, the persistent service, and an optional patch to remove the maximum encoding sessions limit.
To perform the installation, we must:
We can check it like this:
The example image shows that "blacklist nouveau" is already added to the blacklist.
If in our case it doesn't show: blacklist nouveau
We add it like this so it's not used and we can install the Nvidia driver.
(If we have installed the post-installation script from tteck or xshok, we can skip this step as it's not necessary since these repositories are already added.)
Update the packages and Proxmox
Before we start, let's install two packages we'll need, git and the kernel headers to install the drivers:
To begin, we need to know what the latest stable driver available is:*
(If we're going to install the patch to bypass the maximum encoding limit, we need to make sure that patch is available for the driver version we're going to install.) We can check it here.
We can check the complete list of Drivers here
When it shows us the result, we copy the number and replace "/latest.txt" with it.
For example, like this:
Once inside the directory, we copy the link of the installer that ends with the .run extension
For example:
We download the driver we copied earlier.
We give it execution permissions.
We execute.
Once finished, we reboot.
After Proxmox has rebooted, we continue with the installation. We execute:
Now we add to etc/modules:
We save: ctrl + x.
We update initramfs:
Next, we create rules to load the drivers at boot for nvidia and nvidia_uvm:
We paste:
We save: ctrl + x
Now we install NVIDIA driver persistence:
We check that the driver is installed and the service is running:
Now as an option, we patch the nvidia driver to remove the maximum encoding sessions. According to the developer, the NVENC patch removes the restriction on the maximum number of simultaneous NVENC video encoding sessions imposed by Nvidia on consumer-level GPUs.
First, we need to obtain this data:
Let's say, for example, that we're going to use the Plex LXC from tteck's script with ID100. If we have it running, we turn it off.
If there are any, we comment out all lines where it appears:
and we paste this inside the LXC configuration file, which corresponds to the data we obtained with: ls -l /dev/nv*
(the numbers may vary from one system to another)
We save: ctrl + x.
We run the LXC and we're going to install the Nvidia driver inside it. IMPORTANT: we do this installation from the LXC console, not from Proxmox
When this screen appears, we select everything by default, each time it asks us.
Once the installation is finished, we check that everything is correct
As we can see, the Plex LXC container makes use of the Nvidia graphics card from our Proxmox host.
If we want any LXC to use our graphics card, we simply follow the same steps.
If we want to use the Nvidia graphics card in Docker, we need to install nvidia-docker2 as an extra.
Inside the LXC where we have Docker, we can do it with this simple script:
If you found this tutorial helpful and useful, you can buy me a Ko-fi! Thank you! 😊