Proxmox: GPU Passthrough
This guide: Proxmox PCI-Passthrough – gareth.com has almost everything you need.
The process is quite straightforward. Ensure that the following modules are
added to your /etc/modules
file on your Proxmox node:
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
Blacklist the graphics drivers form your Proxmox node, so that the graphics cards will be available for use:
echo "blacklist nvidia" >> /etc/modprobe.d/blacklist.conf
echo "blacklist radeon" >> /etc/modprobe.d/blacklist.conf
echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf
Find the ID of the graphics card you wish to pass-through.
lspci | grep VGA
If you have multiple graphics cards installed, Check you have the right one.
They might share the same vendor ID if they are the same model. Once you have
the ID, (it will be something like 03:00
, get the vendor IDs:
lspci -n -s 03:00
Add the resultant IDs to /etc/modprobe.d/vfio.conf
options vfio-pci ids=10de:1380,10de:0fbc disable_vga=1
Load the new configs
update-initramfs -u
And restart the server.
Finally, add the PCI device to the hardware section of your VM.
Notes
You need to be aware of the IOMMU groups that each device is attached to. See Intro to IOMMU groups for KVM virtual machines - YouTube.
Also, one GPU will be attached to the Proxmox host device, and its ROM will be written in such a way that it will not work correctly for virtualisation, even if it appears to be an available option. You will need to patch the ROM (See GPU BIOS Info) if you only have one GPU installed, or you have several others but also want to use this one.
Add USB Devices too
You might be doing GPU passthrough so that you can drive an OS directly through your PC connected to a monitor. In this case, you probably want to passthrough some USB devices (like keyboard, mouse and perhaps bluetooth) too. This is even easier than GPU passthrough.
The command lsusb
will help identify usb ports and devices. You may want to
passthrough bluetooth, keyboard and mouse. They will need to be plugged in to
the machine hosting Proxmox as you use the GUI to add them.
Virtualised GPUs
You can go one step beyond passthrough GPUs, and virtualise GPUs to split them across multiple VMs. This is more involved. See Proxmox vGPU Gaming Tutorial - Share Your GPU With Multiple VMs! - YouTube
The AMD Reset Bug
Many AMD graphics cards have a bug where they cannot be initialised more that once per power cycle. Since the booting of the Proxmox server counts as the first initialisation, they fail when trying to passthrough to a VM. There are some fixes available, for some cards.
See Working around the AMD GPU Reset bug on Proxmox using vendor-reset – Nicholas Sherlock