1. Configure GRUB
a. Open GRUB:
nano /etc/default/grub
b. Look for this line:
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
c. Update it based on the CPU type:
For Intel CPUs:
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on"
For AMD CPUs:
GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on"
Additional commands may be necessary based on other hardware requirements. For example:
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt pcie_acs_override=downstream,multifunction nofb nomodeset video=vesafb:off,efifb:off"
After saving, update GRUB:
update-grub
2. Update VFIO Modules
Edit the modules file:
nano /etc/modules
Add the following to the file:
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
Save and exit.
3. IOMMU interrupt remapping
Run the following commands:
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
4. Blacklist Drivers
Blacklisting the drivers ensures that the Proxmox host doesn’t try to load the drivers and initialize the device.
echo "blacklist radeon" >> /etc/modprobe.d/blacklist.conf
echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf
echo "blacklist nvidia" >> /etc/modprobe.d/blacklist.conf
5. Add GPU to VFIO
Run this command:
lspci -v
The shell will output the details of each PCI device available on the host. Find the PCI device ID that corresponds with the GPU you want to passthrough. It should look something like this:
01:00.0 VGA compatible controller: NVIDIA Corporation TU102 [GeForce RTX 2080 Ti] (rev a1) (prog-if 00 [VGA controller])
01:00.1 Audio device: NVIDIA Corporation TU102 High Definition Audio Controller (rev a1)
01:00.2 USB controller: NVIDIA Corporation TU102 USB 3.1 Host Controller (rev a1) (prog-if 30 [XHCI])
01:00.3 Serial bus controller: NVIDIA Corporation TU102 USB Type-C UCSI Controller (rev a1)
(Note, the GPU used in this example has additional device IDs for the USB controller and ports. Some may only have IDs for the video and audio devices.)
Make note of the first set of numbers (e.g. 01:00.0 and 01:00.1). We’ll need them for the next step.
Run the command below. Replace 01:00 with whatever number was next to your GPU when you ran the previous command:
lspci -n -s 01:00
Doing this should output your GPU card’s Vendor IDs, usually one ID for the GPU and one ID for the Audio bus. I will look like this:
01:00.0 0300: 10de:1e04 (rev a1)
01:00.1 0403: 10de:10f7 (rev a1)
01:00.2 0c03: 10de:1ad6 (rev a1)
01:00.3 0c80: 10de:1ad7 (rev a1)
Next, add these Vendor IDs to the VFIO:
echo "options vfio-pci ids=10de:1e04,10de:10f7,10de:1ad6,10de:1ad7 disable_vga=1"> /etc/modprobe.d/vfio.conf
(Note, if you’re only passing through one GPU, and the system isn’t using any other VGA-compatible device, disable_vga=1
may not be necessary. In most homelab setups where you leave an iGPU for the host and pass a dGPU to a VM, using disable_vga=1 is a good idea.)
Next, run this command:
update-initramfs -u
Finally, reboot the host.
reboot
The system is now ready to pass through the dGPU to a Windows or Linux-based VM.
Follow these guides to add your GPU to a Windows or Ubuntu VM in Proxmox.
Sources:
https://www.reddit.com/r/homelab/comments/b5xpua/the_ultimate_beginners_guide_to_gpu_passthrough/
Leave a Reply