How to Set Up GPU Passthrough on Proxmox

  • Post author:WunderTech
  • Post last modified:May 10, 2024
  • Post category:Proxmox
  • Reading time:12 mins read

Share what you're reading!

In this tutorial, we will look at how to set up GPU Passthrough on Proxmox. If you’re ever interested in passing a GPU to a virtual machine in Proxmox, it can be done using GPU passthrough. This means that the entire PCI device is passed through to the virtual machine and it will use the VM as if it’s part of the local device.

How to Set Up GPU Passthrough on Proxmox

Before we look at how to set up GPU passthrough on Proxmox, I want to be entirely clear that GPU passthrough can be a huge pain to set up, so we will look at a few disclaimers before proceeding.

Disclaimers for GPU Passthrough

The guide below shows a basic setup that will work for some people. I am saying this because I have experienced it myself – I have two Proxmox nodes set up in a cluster. One has an AMD processor and the second has an Intel processor.

I spent an entire weekend trying to get the AMD system working with GPU passthrough and I simply couldn’t do it (using every workaround I could find). I moved the GPU to the Intel machine, followed the process below and it was working in literally 5 minutes.

For that reason, here are a few points that I will make before we look at how to set up GPU passthrough on Proxmox:

  • The steps below will work in a perfect world. I don’t know the percentage of people who will have success, but this is where I think everyone should start.
  • The newer version of Proxmox seems to work better with GPU passthrough than the older ones, so I’d consider upgrading if you run into issues.
  • You must ensure that the Proxmox host does not attempt to use the GPU. This can be as simple as making a BIOS change (and setting the default GPU) or as difficult as setting up a script in Proxmox to disable the GPU at boot.
  • Passing the GPU to the VM and seeing the GPU in the VM does not mean that the process has worked. Until the drivers for the GPU are successfully installed and you see GPU activity, you may run into issues.
  • In extreme cases, you may have to add a ROM file for your GPU. In more extreme cases, you may have to patch the ROM file further before adding it.
  • If you run into issues, troubleshoot each step one by one because it’s very easy to start randomly changing things hoping they will work which can have a severe impact on your ability to actually solve the problem.

Configuring GPU Passthrough on Proxmox

With the disclaimers out of the way, we will look at how to set up GPU passthrough on Proxmox.

1. Ensure that IOMMU is enabled in the BIOS, then we will enable IOMMU in Proxmox. Run the command below to modify the GRUB bootloader.

nano /etc/default/grub

2. Comment out the line below by adding a # in front of it.

#GRUB_CMDLINE_LINUX_DEFAULT="quiet"

3. Add a new line and add one of the two lines below, depending on if you’re using an AMD processor or an Intel Processor.

AMD:

GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on"

Intel:

GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on"
grub changes in proxmox. How to Set Up GPU Passthrough on Proxmox

4. Save the file, then run the command below to update GRUB. It will take a few seconds to complete.

update-grub
updating grub in proxmox.

5. Run the command below to edit the modules file and add the required modules.

nano /etc/modules

This file will be blank, so add the information below, then save the file.

vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd

Configuring IOMMU Isolation

Every motherboard will have different IOMMU groups. You might get lucky and have very isolated groups (meaning that each device has its own IOMMU Group), or you might get unlucky and have to try and force it. Before you drive yourself crazy, check to see if the GPU has its own IOMMU group.

1. Run the command below to find the GPU, then check the group number for the GPU. In my case, it’s group 16. Please note that there may be two – one for the GPU and one for the audio device for the GPU.

lspci -v
gpu group number in proxmox.

2. Once you have the group number, run the command below to find all of the IOMMU groups. Please note that the group number above was group 16 and in the screenshot below, group 16 only has two total lines – one for the GPU and one for the audio device on the GPU.

find /sys/kernel/iommu_groups/ -type l
IOMMU group numbers in proxmox.

3. Since my GPU doesn’t have any additional devices in the same group, I can proceed. However, if you do notice that the GPU you’re using is in the same group as another device, run the command below to attempt to isolate the device, reboot Proxmox, then run steps one and two above again.

You can also read about IOMMU Interrupt Remapping here.

echo "options vfio_iommu_type1 allow_unsafe_interrupts=1" > /etc/modprobe.d/iommu_unsafe_interrupts.conf

Making the Necessary Virtual Machine Changes

After running the steps above, the actual process for configuring GPU passthrough is complete. However, you must set up a virtual machine to confirm that GPU passthrough is working. In the example below, I am using a Windows 10 VM, but the process should work for any OS (but the driver installation will be different).

1. Ensure that you’re using q35 as the Machine type and OVMF (UEFI) as the BIOS. Also, make sure that the Memory does not have Ballooning Device enabled.

VM setup in proxmox for GPU passthrough.

2. After the VM has been set up, add the GPU to the VM by selecting Add, then PCI Device. Ensure that All Functions, ROM-bar, Primary GPU, and PCI-Express are all enabled.

Please keep in mind that all VMs are different, so you may have to do certain things like enabling RDP in Windows to access the VM before passing through the GPU.

adding a GPU to a proxmox vm.

3. Start the VM, then install the GPU drivers! If the drivers install properly, you should be able to see the GPU inside of the VM.

Troubleshooting GPU Passthrough

If the process above on configuring GPU passthrough on Proxmox didn’t work, you are in the unlucky group that has to make additional changes and/or configurations.

The first thing I would try is to blacklist the GPU drivers so that Proxmox doesn’t attempt to use the GPU. Run the command below, then add the three lines below to the file and save. After making the changes, reboot Proxmox and try again.

nano /etc/modprobe.d/blacklist.conf
blacklist radeon
blacklist nouveau
blacklist nvidia
blacklisting GPU drivers in proxmox.

If blacklisting the GPU drivers does not work, there are various things that can be causing issues. Start with the troubleshooting steps in the Proxmox documentation then head over to the Proxmox forums and try and find similar hardware configurations.

To be clear, there are many items that can potentially cause issues with GPU passthrough on Proxmox at this step, and rather than adding to the confusion by suggesting general steps, it’s best to try and find out if there are any changes you can make based on the hardware you’re using.

Conclusion & Final Thoughts

This tutorial looked at how to set up GPU passthrough on Proxmox. In a perfect world, you’ll run the steps above and the GPU passthrough will work perfectly. However, there are many cases where you will run into issues and potentially even give up as I did with my AMD device.

In my opinion, GPU passthrough on Proxmox is heavily reliant on the motherboard and BIOS, which explains why some people have no issues at all and others are running into tons of issues. Not that it’s ideal to update a BIOS, but that could be a necessary step for some as well.

Thanks for checking out the tutorial on how to set up GPU passthrough on Proxmox. If you have any questions, please leave them in the comments!

WunderTech

Frank is an IT professional with 14+ years experience and the creator of WunderTech. He focuses on sharing his experience with others on computer hardware, servers, software, networking, and self-hosted apps. He has a BS in Computer Information Systems and an MBA. Learn more about Frank in his bio.