TechBuzzPro

GPU Passthrough: How to Pass a GPU to a VM

· 5 min read · Windows & PC

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

GPU passthrough lets a virtual machine use a physical graphics card directly, giving near-native performance for gaming, rendering, or compute tasks. To do it, your CPU and motherboard must support hardware virtualization (Intel VT-d or AMD-Vi), you need a second GPU for the host, and your hypervisor must support PCIe passthrough. The steps below cover the common Linux KVM/QEMU setup, which is the most widely documented method.

What You'll Need

  • A CPU with Intel VT-d or AMD-Vi enabled in the BIOS/UEFI.
  • A motherboard that supports IOMMU and has the GPU in a PCIe slot with its own IOMMU group.
  • Two GPUs: one for the host (integrated graphics is fine) and one to pass through.
  • A Linux distribution with KVM/QEMU and libvirt installed (e.g., Ubuntu, Fedora, Arch).
  • Basic comfort with the terminal and editing configuration files.

Step-by-Step

  1. Enable virtualization and IOMMU in the BIOS/UEFI. Reboot and enter the firmware settings. Turn on Intel VT-d (sometimes called “VT-d” or “Directed I/O”) or AMD-Vi (sometimes “IOMMU”). Also enable “Above 4G Decoding” if present. Save and exit.
  2. Enable IOMMU in the kernel. Edit your bootloader configuration. For GRUB, add intel_iommu=on iommu=pt (Intel) or amd_iommu=on iommu=pt (AMD) to the kernel command line. Update GRUB and reboot. Confirm IOMMU is active with dmesg | grep -i iommu.
  3. Check IOMMU groups. Run a script such as find /sys/kernel/iommu_groups/ -type l to list devices per group. The GPU you want to pass through should be in its own group, or at least grouped only with other devices you can also pass through. If it shares a group with critical host devices, you may need to move the card to another PCIe slot or use the ACS override patch (risky and not recommended for beginners).
  4. Bind the GPU to vfio-pci. Identify the vendor and device IDs with lspci -nn | grep -i vga. Create a modprobe configuration file (e.g., /etc/modprobe.d/vfio.conf) with options vfio-pci ids=10de:1234,10de:5678 (replace with your IDs). Also ensure the host does not load the GPU's normal driver (e.g., nouveau or amdgpu) by blacklisting it or using softdep. Update initramfs and reboot.
  5. Verify the binding. After reboot, run lspci -nnk and check that the GPU shows “Kernel driver in use: vfio-pci”. If it still shows the original driver, revisit the blacklist and initramfs steps.
  6. Create a VM with the GPU attached. Using virt-manager (GUI) or virsh (CLI), add a PCI host device to the VM. In virt-manager, open the VM's details, click “Add Hardware”, choose “PCI Host Device”, and select the GPU and its audio function (if present). For best results, also set the VM's firmware to UEFI (OVMF) and use a Q35 machine type.
  7. Install drivers inside the VM. Start the VM and install the official GPU driver for the guest OS (e.g., NVIDIA or AMD driver). The VM should now see the physical GPU and output video through it if you connect a monitor to the passed-through card.
  8. Test and refine. Run a graphics benchmark or game inside the VM to confirm performance. If you need audio over HDMI, pass through the GPU's audio device as well. For lower latency, consider CPU pinning and hugepages, but these are optional.

Common Mistakes

  • Forgetting to enable VT-d/AMD-Vi in the BIOS — the most frequent cause of failure.
  • Not blacklisting the host GPU driver, so the host grabs the card before vfio-pci can.
  • Passing through a GPU that shares an IOMMU group with essential devices like the USB controller or SATA controller, which can crash the host.
  • Using a VM without UEFI firmware; some GPUs require UEFI for passthrough to work properly.
  • Expecting passthrough to work on a laptop with a single GPU — usually not possible without advanced tricks and a second GPU.

Tips

  • Use an integrated GPU for the host to keep the discrete card free for passthrough.
  • Keep your hypervisor and guest drivers up to date; improvements and fixes are common.
  • Test with a simple Linux VM first to confirm passthrough works before installing Windows and games.
  • Document your working configuration (kernel parameters, modprobe files) so you can restore it after updates.
  • If you use NVIDIA, some consumer cards require a workaround to avoid “Code 43” in Windows VMs; check the official NVIDIA documentation for details.

Troubleshooting

If the VM fails to start or the GPU does not appear, check the VM's logs (e.g., virsh dumpxml and journalctl -u libvirtd). Common fixes: ensure the vfio-pci module loads at boot, verify the GPU IDs are correct, and confirm the VM's XML includes the PCI device with the right address. If the host crashes when starting the VM, the GPU likely shares an IOMMU group with a critical device — try a different PCIe slot or consider a different motherboard. If the guest sees the GPU but performance is poor, check that the VM is using UEFI and that the GPU is not also bound to the host driver. For audio issues, pass through the GPU's audio function separately. If you get a “Code 43” error in Windows, it often means the driver detected a virtual environment; some users resolve it by hiding the hypervisor (not officially supported) or using a different driver version.

Frequently Asked Questions

Can I pass through my only GPU?

It is possible with single-GPU passthrough, but it requires shutting down the host's display and is more complex. For beginners, a second GPU is strongly recommended.

Does GPU passthrough work on Windows as the host?

Windows Hyper-V supports Discrete Device Assignment (DDA) for some GPUs, but it is limited and not as flexible as Linux KVM. Most guides focus on Linux.

Will passthrough work with any GPU?

Most modern AMD and NVIDIA GPUs work, but some older cards or those with restrictive firmware may not. Check community reports for your specific model.

Do I need a second monitor?

Not necessarily. You can use a monitor connected to the passed-through GPU, or use looking-glass or remote desktop for headless setups. For gaming, a physical monitor on the passed-through card gives the best experience.

Is GPU passthrough safe?

Yes, when configured correctly. The main risk is host instability if you pass through a device in a shared IOMMU group. Always back up your configuration before making changes.