GPU passthrough allows you to dedicate a physical GPU directly to a virtual machine for high-performance computing, gaming, or AI workloads. In this guide, you will learn how to configure a GPU passthrough KVM setup or Proxmox VE host and set up both Linux and Windows guests.
At PerLod Hosting, we specialize in high-performance KVM and Proxmox servers with GPU support. This guide walks you through the exact steps to enable GPU passthrough, so you can replicate it on your own system or hosting environment.
Prerequisites for GPU Passthrough KVM Setup
Before starting GPU passthrough KVM setup, you must confirm your hardware and software can support it, which requires a modern CPU, proper BIOS options, and control over the host machine.
Be sure your system includes:
A dedicated PCIe GPU like NVIDIA or AMD.
IOMMU and VT-d/AMD-Vi support is in both the CPU and the motherboard.
BIOS settings enabled:
Intel: VT-d = Enabled.
AMD: SVM = Enabled, and IOMMU = Enabled.
Above 4G Decoding = Enabled.
Resizable BAR = Auto or Disabled if you encounter instability.
Operating system: Debian LTS, Ubuntu LTS, or Proxmox VE 8.
Hypervisor: KVM/QEMU or Proxmox VE.
Remember, you must have full control of the host; regular shared VPS instances do not allow raw PCI passthrough.
Verify Hardware and IOMMU Support
The first step is to confirm that your system detects the GPU and supports IOMMU, which ensures that the kernel can properly isolate PCI devices for passthrough.
List the GPU and related audio functions with the command below:
Bash
lspci-nn|egrep-i'vga|3d|display|audio'
Check IOMMU support in kernel logs by using the following command:
Bash
dmesg|egrep-i'iommu|dmar|amd-vi'
Note: If dmesg doesn’t show IOMMU-related entries, it means the kernel hasn’t enabled it yet. We will fix it in the next step by editing the GRUB configuration.
Enable IOMMU in GRUB For GPU Passthrough
The GRUB bootloader controls kernel parameters during startup. You must enable IOMMU in Grub to tell the Linux kernel to initialize device isolation required for GPU passthrough.
Open the GRUB configuration file and modify the kernel boot line:
If these modules appear, your system now supports IOMMU.
Check and Isolate IOMMU Groups
Every PCI device belongs to an IOMMU group. GPU passthrough requires your GPU and its audio function to be in its own isolated group, which ensures safe and stable device assignment.
As a last resort, enable the PCIe ACS override patch, though it reduces isolation.
Find GPU Vendor and Device IDs
In this step, you need to find your GPU’s vendor and device IDs to bind it correctly to VFIO later. To do this, you can run the command below:
Bash
lspci-nn-s0000:BB:DD.F
Example Output looks like this:
Bash
10de:1e84(GPU)10de:10f8(Audio)
Note these IDs; you will use them in the next step.
Prevent the Host from Using GPU Drivers
The host OS must not claim the GPU before VFIO; otherwise, passthrough will fail, so you must blacklist the default GPU drivers and manually bind the device to VFIO.
Use the commands below to blacklist host GPU drivers:
Bash
echo-e"blacklist nouveau\noptions nouveau modeset=0"|sudotee/etc/modprobe.d/blacklist-nouveau.confecho-e"blacklist nvidia\nblacklist nvidia_drm\nblacklist nvidia_uvm"|sudotee/etc/modprobe.d/blacklist-nvidia.confecho-e"blacklist radeon\nblacklist amdgpu"|sudotee/etc/modprobe.d/blacklist-amd.conf
After reboot, verify the kernel driver with the following command:
Bash
lspci-nnk-s0000:BB:DD.F
If you see “Kernel driver in use: vfio-pci”, the GPU is successfully bound.
Configure Libvirt VM for GPU Passthrough
At this point, you must give your VM access to the GPU by editing the VM’s XML configuration to assign the GPU device and its audio function.
Edit the XML with the command below:
Bash
sudovirsheditvm-name
Use Q35 as the machine type, host-passthrough CPU mode, and hide the KVM vendor to prevent NVIDIA Code 43:
HTML/XML
1<domaintype='kvm'>2<name>gpu-vm</name>3<memoryunit='GiB'>16</memory>4<vcpuplacement='static'>8</vcpu>56<os>7<typearch='x86_64'machine='q35'>hvm</type>8<loaderreadonly='yes'type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>9<nvram>/var/lib/libvirt/qemu/nvram/gpu-vm_VARS.fd</nvram>10</os>1112<features>13<acpi/>14<apic/>15<hyperv>16<vendor_idstate='on'value='KVMhidden'/>17</hyperv>18<kvm>19<hiddenstate='on'/>20</kvm>21</features>2223<cpumode='host-passthrough'check='none'>24<topologysockets='1'dies='1'cores='4'threads='2'/>25</cpu>2627<devices>28<!-- VirtIO disk and NIC recommended -->29<disktype='file'device='disk'>30<drivername='qemu'type='qcow2'cache='none'io='native'/>31<sourcefile='/var/lib/libvirt/images/gpu-vm.qcow2'/>32<targetdev='vda'bus='virtio'/>33</disk>3435<interfacetype='bridge'>36<sourcebridge='br0'/>37<modeltype='virtio'/>38</interface>3940<!-- The GPU and its audio function -->41<hostdevmode='subsystem'type='pci'managed='yes'multifunction='on'>42<source>43<addressdomain='0x0000'bus='0xBB'slot='0xDD'function='0x0'/>44</source>45<rombar='on'/>46<addresstype='pci'domain='0x0000'bus='0x00'slot='0x08'function='0x0'/>47</hostdev>4849<hostdevmode='subsystem'type='pci'managed='yes'>50<source>51<addressdomain='0x0000'bus='0xBB'slot='0xDD'function='0x1'/>52</source>53<addresstype='pci'domain='0x0000'bus='0x00'slot='0x08'function='0x1'/>54</hostdev>5556<!-- Optional: add a keyboard-video-mouse off if you rely on the GPU -->57<video>58<modeltype='none'/>59</video>60</devices>61</domain>
Once you are done, apply and start it with the following commands:
Bash
sudovirshdefine/etc/libvirt/qemu/gpu-vm.xmlsudovirshstartgpu-vmsudovirshconsolegpu-vm# for Linux install, otherwise use VNC if you kept a virtual GPU
Configure GPU Passthrough in Proxmox VE
If you’re using Proxmox, you can enable GPU passthrough via the web interface or manually edit the VM config file.
In Proxmox GUI, open your VM, navigate to:
Bash
Hardware → Add → PCIDevice
From there, select the GPU and its Audio device and enable the following options:
All Functions: ON
ROM-Bar: ON
PCI-Express: ON
Primary GPU: optional
To edit it manually, open the VM configuration file:
Then, start the VM and check for logs with the command below:
Bash
journalctl-xe|egrep-i'vfio|qemu|hostpci'
Install and Verify GPU Drivers Inside Guest OS
Once the VM boots, you can install GPU drivers in your guest operating system so the GPU can function properly.
For Linux Guests, for example, Ubuntu, run the system update and install NVIDIA drivers, and verify them with the commands below:
Bash
# Updatesudoaptupdate&&sudoaptupgrade-y# NVIDIA drivers exampleubuntu-driversdevicessudoaptinstallbuild-essentialdkms-ysudoaptinstallnvidia-driver-535-y# pick recommended version from the previous command# Verifynvidia-smi
For AMD: On Ubuntu 22.04 and later, most AMD GPUs use the amdgpu driver by default. For the Pro stack, install Vulkan drivers:
Bash
sudoaptinstallmesa-vulkan-drivers-y
Note: For compute workloads, use ROCm and install the appropriate ROCm packages.
For Windows guests:
You must install the official GPU drivers from NVIDIA or AMD.
If you removed the virtual display, connect via RDP after installing the driver.
For older NVIDIA drivers that can detect virtual machines, make sure the KVM hidden and vendor_id settings are added in the XML.
You can optionally turn on MSI for the GPU to reduce system interrupts. In Windows, use MSI Utility v3 and check the box for your GPU.
To verify:
NVIDIA: The GPU appears in Device Manager, and nvidia-smi works in PowerShell.
AMD: The GPU appears in Device Manager, and performance data shows up in Task Manager.
Test GPU with CUDA and PyTorch in Linux
Once the GPU drivers are installed, test if CUDA and PyTorch detect the GPU correctly.
Install the CUDA toolkit with the commands below:
Bash
sudoaptinstallnvidia-cuda-toolkit-ynvcc--version
Create a quick Python test with the command below:
Use Q35 machine type and OVMF (UEFI) firmware. Don’t add a second virtual GPU if the passed-through GPU is your main one.
Black screen on boot: If you removed the virtual display, set the passed GPU as the primary display. Make sure a monitor is connected, or use an HDMI dummy plug if your card needs it.
Driver won’t build on Linux due to Secure Boot: Either sign the kernel modules or turn off Secure Boot in OVMF.
Host loads nouveau/nvidia/amdgpu after updates: Check that your blacklist files still exist, then rebuild the initramfs and reboot:
Bash
sudoupdate-initramfs-u-kallsudoreboot
Rollback and Remove Passthrough Configuration
If something breaks or you want to revert, you can simply remove all passthrough configurations. To remove them, you can run the commands below:
GPU passthrough KVM setup, or with Proxmox VE, allows your virtual machines to use real GPU power for deep learning, rendering, or gaming. By following the guide steps, your VM can fully utilize your GPU safely, efficiently, and with full control.
If you’re looking to host virtual machines with dedicated GPU performance, PerLod offers optimized VPS hosting solutions for Proxmox and KVM.
We hope you enjoy this guide. Subscribe to X and Facebook channels to get the latest updates and articles on GPU passthrough.
We use cookies to run PerLod and to understand how the site is used. You can accept everything, or open Manage to turn individual categories off. Cookie policy.