Skip to content

GPU Passthrough

GPU passthrough allows a virtual machine to have direct access to your dedicated GPU, enabling near-native graphics performance for gaming or GPU-accelerated workloads.

  • Completed KVM Setup
  • Two GPUs (integrated + dedicated, or two dedicated)
  • VT-d/AMD-Vi and IOMMU enabled in BIOS
  • IOMMU groups properly separated
Terminal window
virt-host-validate

Ensure QEMU and KVM show PASS. IOMMU warnings are expected if not yet configured.

Find your dedicated GPU:

Terminal window
lspci -nn | grep -E "VGA|Audio" | grep -i nvidia

Example output:

01:00.0 VGA compatible controller [0300]: NVIDIA Corporation [...] [10de:2560]
01:00.1 Audio device [0403]: NVIDIA Corporation [...] [10de:228e]

Note the IDs: 10de:2560 and 10de:228e

Create /etc/modprobe.d/vfio.conf:

Terminal window
options vfio-pci ids=10de:2560,10de:228e
softdep nvidia pre: vfio-pci

Create /etc/modprobe.d/nvidia.conf to prevent loading:

Terminal window
# Prevent NVIDIA driver from binding to passthrough GPU
install nvidia /bin/false
install nvidia_modeset /bin/false
install nvidia_drm /bin/false

Add VFIO modules to mkinitcpio. Edit /etc/mkinitcpio.conf:

Terminal window
MODULES=(vfio_pci vfio vfio_iommu_type1)

Regenerate:

Terminal window
sudo mkinitcpio -P

After reboot, verify VFIO is bound to the GPU:

Terminal window
lspci -nnk -d 10de:2560

Should show Kernel driver in use: vfio-pci

Terminal window
sudo pacman -S --needed qemu-full libvirt virt-install virt-manager \
virt-viewer dnsmasq bridge-utils openbsd-netcat edk2-ovmf swtpm \
iptables-nft libosinfo
Terminal window
paru -S virtio-win

The ISO is placed at /var/lib/libvirt/images/virtio-win.iso

When creating the Windows VM in virt-manager:

  1. Firmware: Select UEFI (OVMF)
  2. Add Hardware > PCI Host Device: Add your GPU (both VGA and Audio)
  3. Add VirtIO disk instead of SATA
  4. Attach VirtIO ISO as CD-ROM for driver installation

Edit the VM XML (virsh edit vmname):

<features>
<hyperv>
<vendor_id state="on" value="randomid"/>
</hyperv>
<kvm>
<hidden state="on"/>
</kvm>
</features>

This hides the hypervisor from the guest (helps with NVIDIA driver detection).

For low-latency display without connecting a monitor:

  1. Install Looking Glass client on host
  2. Install Looking Glass host application in Windows guest
  3. Configure shared memory in VM XML

See the Looking Glass documentation for details.

Check IOMMU groups - GPU must be alone or with related devices only:

#!/bin/bash
for d in /sys/kernel/iommu_groups/*/devices/*; do
n=$(basename $(dirname $(dirname $d)))
echo "IOMMU Group $n: $(lspci -nns ${d##*/})"
done
  • Ensure hypervisor is hidden (XML tweaks above)
  • Update to latest NVIDIA drivers in guest
  • Disable Message-Signaled Interrupts if needed