Welcome back to What’s New Andrew! In today’s video, I’m diving into the nitty-gritty of setting up PCI Passthrough within Proxmox and showing you how to pass an NVIDIA GPU into Plex for efficient hardware transcoding. If you want your Plex server to handle streaming with ease across different devices and resolutions, this tutorial is a game-changer!
Without hardware transcoding, your CPU can become overwhelmed, leading to frustrating buffering issues and potential server crashes. By enabling hardware encoding, you’ll streamline performance, reduce server strain, and ensure a smooth streaming experience for all your media needs.
Don’t miss out on this essential guide to optimizing your Plex server. Hit that play button and let’s get your setup running flawlessly!
Be sure to subscribe to “What’s New Andrew” for more tech tips and tutorials!
PCI Passthrough into a Plex VM is done in two parts. The first part is to update the Proxmox Node to enable PCI Passthrough. The second part is to attach the PCI device to the VM running Plex, install the necessary drivers, and enable Hardware Transcoding. The commands below are what are used in the video. If you run into any issues, feel free to drop a comment, and if you like the video, hit the thumbs up and please consider subscribing if you have not already.
To see if the NVIDIA GPU you have or are interested in purchasing is supported, check out the NVIDIA GPU Support Matrix here: https://go2wna.com/JnqqB
Updates on the Proxmox Node to enable PCI Passthrough
Step 1: Enable IOMMU by updating Grub. IOMMU (Input-Output Memory Management Unit) connects a direct-memory-access (DMA)-capable I/O bus to a system’s main memory by mapping virtual addresses to physical addresses:
nano /etc/default/grub
Find the following line in the file and add the appropriate IOMMU statement based on your processor type (AMD or Intel):
GRUB_CMDLINE_LINUX_DEFAULT=”quiet”
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on"
OR
GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on"
Save the file and update grub with the following command:
update-grub
NOTE: (OPTIONAL IF YOU DO NOT UPDATE GRUB ABOVE) If you have an efi boot system enable IOMMU by editing the following file (uncommon)
nano /etc/kernel/cmdline
%> intel_iommu=on
- OR -
%> amd_iommu=on
Save file and close
proxmox-boot-tool refresh
Setp 2: Set up Proxmox to load the VFIO modules at boot. Proxmox 6.4+ already has VFIO modules enabled, but I still like to make this update as it can reduce the headaches later. And it does not impact anything by adding the updates just to be sure!
nano /etc/modules
Inside that file add the following four lines:
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
nano /etc/modprobe.d/blacklist.conf
In that file add the following lines to blacklist any drivers:
blacklist radeon
blacklist nvidia
blacklist nouveau
blacklist nvidiafb
blacklist snd_hda_intel
Step 4: (Optional) – There are a couple of additional lines that can aid in reducing sound crackles that may occur. Adding the following two lines will help with this should you run into these. I go ahead and run by default, but it is optional if you would like to make these changes
echo "options vfio_iommu_type1 allow_unsafe_interrupts=1" > /etc/modprobe.d/iommu_unsafe_interrupts.conf
echo "options kvm ignore_msrs=1" > /etc/modprobe.d/kvm.conf
Step 5: Now we can find the device we would like to passthrough. Run the following command to list all of your pci devices to ensure you see your GPU listed:
lspci
If you do not see your device, ensure it is installed and not sitting on your desk by the machine. 😅 Also make sure any auxiliary power is connected to the card if necessary. To get the hardware values for your device you will need to enter the ID number for it in the following command where ##:## is the ID of the device:
lspci -n -s ##:##
Note the hex values for the next step. They will be letter/number values in the format abcd:wxyz.
Using the hex values comma separated, enter the following line and hit enter to update. Be sure to include all of the values for your device. If you make a mistake, you can edit the /etc/modprobe.d/vfio.conf file to make corrections:
echo "options vfio-pci ids=####.####,####.####,####.#### disable_vga=1"> /etc/modprobe.d/vfio.conf
Now update with the changes you made
update-initramfs -u -k all
And Reboot the system. We are done with the changes you need to make with the Proxmox Node. All other changes will be done in the VM for Plex
Create a VM to run Plex on Proxmox for PCI Passthrough
Step 1: Create your VM and install Plex if you do not already have a VM running Plex. Follow the steps in the video to set up and confirm that it works
Commands I used to install Plex as shown in the video. First is to add the repository for plex to our list of repositories in Linux:
echo deb https://downloads.plex.tv/repo/deb public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list
The next command will add the plex key. Be sure to include the trailing – in the command:
curl https://downloads.plex.tv/plex-keys/PlexSign.key | sudo apt-key add -
The final two commands will do an update to bring in the details we added from the lines above. Then we will install plex with the second line:
sudo apt update
sudo apt install plexmediaserver
Once you install Plex you can add storage using a NAS or with this video showing how to Increase Storage on a VM in Proxmox if you do not have access to a NAS on your network.
Attach PCI hardware to your VM so that the GPU will be available to Plex for Hardware Transcoding
Step 1: Attach the PCI device to your VM in the hardware section of Proxmox for the VM.
See in the video where to choose hardware -> Add PCI Device -> Raw Device & Select your GPU that was passed through
Step 2: Disable nouveau drivers and run an update
sudo bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
sudo bash -c "echo options nouveau modset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
sudo update-initramfs -u
Now reboot your VM so that the drivers will unload:
sudo reboot
Step 3: Install the NVIDIA drivers in ubuntu so that you can use the GPU for hardware transcoding. If you are using Debian and not Ubuntu you can see this site for how to install drivers, but it is a bit more involved which is why I chose Ubuntu: https://wiki.debian.org/NvidiaGraphicsDrivers
Commands to install the drivers:
sudo apt update
Install the following packages in order to successfully install the drivers in the next step:
sudo apt install build-essential libglvnd-dev pkg-config
build-essential
is a package in Debian-based Linux distributions (like Ubuntu) that includes a collection of essential tools for compiling software from source.- The
libglvnd-dev
package includes the headers and other files necessary for developing applications that use GLVND. Installing this package allows you to compile and link programs against the GLVND library, ensuring that your applications can use OpenGL functions provided by different vendors’ drivers. pkg-config
is a tool that helps manage the compilation process of applications and libraries by providing a unified interface to query the information about installed libraries.
Now install the NVIDIA drivers!
sudo ubuntu-drivers autoinstall
sudo reboot
nvidia-smi
You should see a readout showing any transcoding that is currently being done by your GPU.
Step 5: Enable hardware transcoding inside Plex
Follow the final steps in the video to select your GPU and enable hardware transcoding!
Congratulations! You now have hardware transcoding successfully implemented on you Plex server!