Add GPU to VM (Passthrough)

Hardware: GPUs and Coral-TPU~15 minView script

Give one of your GPUs to a virtual machine with near-native performance. ProxMenux detects Intel / AMD / NVIDIA, validates IOMMU, analyses the GPU's IOMMU group to pass every sibling device together, configures VFIO on the host, writes the right hostpci lines into the VM config, and applies vendor-specific fixes where needed.

What this does

Automates the relevant host and hostpci configuration steps described in the Proxmox PCI passthrough documentation. It checks assignments in other guests and offers conflict-handling choices. These checks do not guarantee support for every GPU, reset method or guest driver.

Who is this for?

You have a physical GPU in your Proxmox host and you want a virtual machine (Windows gaming, macOS, a headless GPU compute node, a VM-based media server) to use it directly. Passing a GPU to a VM is not the same as passing it to an LXC — VMs need the kernel to treat the GPU as a VFIO device (essentially "the host won't touch it"), which means the host cannot use that GPU for anything else while the VM is running. For LXC transcoding / compute, use Add GPU to LXC instead — it shares the GPU and does not need VFIO.

Before you start

  • A supported GPU physically installed. The script detects Intel, AMD and NVIDIA via lspci.
    lspci | grep -iE 'VGA|3D|Display'
  • IOMMU support must be available in hardware and enabled in firmware where required (Intel VT-d or AMD-Vi). The script checks the running system and can configure Linux boot parameters; it cannot change BIOS/UEFI settings or prove that every inactive IOMMU is disabled in firmware.
  • This assistant requires the q35 machine type and refuses i440fx. Machine type is separate from BIOS/UEFI firmware; changing an existing VM chipset requires planning and is not performed automatically.
    qm config VMID | grep machine
  • Preferably more than one GPU in the host, or console access on another output (IPMI, KVM-over-IP, serial). Once you pass the only GPU to a VM, the host console goes dark. With two NVIDIA GPUs you can pass one to a VM and keep the other on the host — the script handles this per-BDF (see NVIDIA in the vendor notes below).
  • If you installed NVIDIA Drivers on the Host, selected functions are reserved for vfio-pci rather than nvidia. The nvidia module can remain available for other cards outside the affected IOMMU group; verify them with nvidia-smi.

VM passthrough vs LXC sharing — pick one per GPU

A GPU bound to vfio-pci for VM passthrough cannot simultaneously be used by the host or an LXC. If you have two GPUs, you can dedicate one to each path. If you have only one, choose:
  • VM route (this page): full hardware access, but exclusively for the VM that owns the GPU while it's running.
  • LXC route (Add GPU to LXC): shared with the host and other containers, great for transcoding, no VFIO magic needed.

Running the installer

Open ProxMenux on the host, go to Hardware: GPUs and Coral-TPU → Add GPU to VM.

Menu entry for 'Add GPU to VM' inside Hardware: GPUs and Coral-TPU

How the script runs

Detection and selection precede the main host/VM changes and a final summary confirms that plan. Enabling IOMMU has its own earlier confirmation and can already edit the boot configuration. Later associated-audio cleanup may also ask for a choice.

Walking through the flow

Step 1

Detect GPUs and check IOMMU

Treats IOMMU as active only when the running kernel has intel_iommu=on or amd_iommu=on and IOMMU groups exist. If the parameter is already saved for the next boot, it continues in pending-reboot mode; otherwise a separately confirmed step can add it with iommu=pt. Its boot-file heuristic uses /etc/kernel/cmdline when a ZFS-root marker such as root=ZFS= exists there; otherwise it uses /etc/default/grub. That heuristic is not proof of the actual bootloader. Newly configured IOMMU takes effect after reboot; inspect the real groups afterwards.

Already ran post-install?

If VFIO IOMMU support was previously configured and is active in the running kernel, this check passes. A saved next-boot setting alone does not prove it is active.
List of detected GPUs with vendor and PCI address
Step 2

Pick a GPU and run pre-flight checks

Once you pick the GPU, the script runs a series of checks that can each block further progress:

  • SR-IOV guard. This assistant refuses VFs and PFs with active VFs because its full-device workflow is not an SR-IOV configuration flow. SR-IOV passthrough must be configured separately on supported hardware.
  • Single-GPU warning. If this is the only GPU in the host, you get a scary dialog reminding you that after reboot the console goes dark — make sure you have SSH or web-UI access from another machine.
  • AMD reset policy. Reads /sys/bus/pci/devices/<pci>/reset_method. An APU or dedicated card without FLR is blocked by this assistant’s policy; an unknown subtype without FLR requires an explicit override. This does not establish universal hardware impossibility.
  • Not in D3cold. Some AMD cards report D3cold power state while idle, which makes them invisible during VM startup. Blocked until you wake the GPU.
  • IOMMU group analysis. Reads /sys/kernel/iommu_groups/ and includes all non-bridge members in the VM plan, possibly network or storage controllers. When the group contains devices from another slot, the script lists them before the summary; check that the host does not need any of them. If IOMMU is pending reboot, real groups are unavailable and the plan initially contains only the selected GPU function; verify isolation after reboot.
  • Audio companion. Two paths, depending on where the audio lives:
    • Discrete GPU: HDMI audio often occupies function .1 of the same PCI slot and is automatically included when detected. If the host was using that audio device, it loses access when the device is reserved for the VM.
    • Intel iGPU (or any GPU without a .1 sibling): the HDMI / analog audio lives on the chipset at a different slot (00:1f.3 typically). The script scans the host, lists every PCI audio controller with its current driver (snd_hda_intel, etc.), and asks you which one(s) to pass through. Default is none — you explicitly opt in.
Step 3

Pick the target VM

Choose a VM from the list. The assistant requires q35 and reuses existing GPU entries where possible. BIOS/UEFI firmware is a separate setting, not a machine type; this check does not automatically change the installed guest’s chipset or boot mode.

VM list with name, ID and status shown as a picker
Step 4

Switch mode — handling the GPU already being elsewhere

The script scans every VM config and every LXC config on the host looking for the GPU you picked. Three possible outcomes:

  • GPU is free. Nothing to do, continue.
  • GPU is in a different VM. If the source VM is currently running, the script aborts — two VMs can't share an exclusive VFIO assignment, and the source VM has to be stopped first. If the source VM is stopped, you get two options: Keep GPU in the source VM's config but disable Start on boot, or Remove the GPU lines from the source VM's config and keep Start on boot. A fast-path also exists: if the GPU is already bound to vfio-pci and the source VM is a plain VM→VM swap, no host reconfiguration is done and no reboot is needed.
  • GPU used by LXC. For ordinary containers, choose keep the GPU configuration and disable Start on boot or remove GPU device configuration and keep Start on boot. Removal deletes the devN entries and, for AMD/Intel, also legacy /dev/dri lxc.mount.entry and lxc.cgroup2.devices.allow rules. OCI containers retain their configuration and are stopped with Start on boot disabled; remove their GPU through OCI manager Apps. Conflict detection is by GPU device family and may include other cards of that family.
Dialog offering to remove the GPU from an LXC before assigning it to the VM

Audio siblings are cleaned up smartly too

After removing GPU assignments from the source VM, the script can offer a checklist of potentially orphaned audio devices. Review it and uncheck anything the source still needs. For example, dedicated-card audio at 02:00.1 may remain while chipset audio at 00:1f.3 is offered for removal. The checklist, not a universal display/audio pairing guarantee, determines the extra removals.
Step 5

(If no .1 sibling) Pick which audio controllers to include

Only happens for Intel iGPU and similar split-audio setups. A checklist shows every PCI audio controller on the host (excluding any already in the GPU's IOMMU group), labelled with its current driver. Select the ones you want — or none, if the VM doesn't need audio from the host hardware.

Checklist dialog with every host PCI audio controller (BDF + driver) when the GPU has no .1 sibling audio

Don't tick audio the host relies on

Assigning an audio controller to the VM can remove host access; it cannot simultaneously belong to another running VM. Leave optional audio unselected when unnecessary, and verify ownership before moving it. PCI audio is not necessarily the source of the host console beep.
Step 6

Review the confirmation summary

Review the final host and VM plan and cancel if it is wrong. It shows the IOMMU group and its device count; members from another slot are listed in the previous step. Cancelling stops the main changes; it does not undo an earlier separately confirmed IOMMU boot-configuration change.

Summary dialog listing host changes (VFIO/blacklist files) and VM config changes (hostpci lines) before applying
Step 7

Host changes are applied

The apply phase performs the host and VM changes. Associated-audio cleanup may still prompt for a selection. Host changes can include:

  • /etc/modules — adds vfio, vfio_iommu_type1, vfio_pci (plus vfio_virqfd on kernels < 6.2).
  • /etc/modprobe.d/vfio.conf — for AMD / Intel, sets options vfio-pci ids=<vendor:device,...> disable_vga=1 so VFIO claims the GPU early at boot. For NVIDIA the file only adds softdep nvidia pre: vfio-pci (plus _drm/_modeset/_uvm) — actual binding is per-BDF via the udev rule below. On AMD, also adds softdep lines forcing vfio-pci to load before radeon / amdgpu.
  • Writes /etc/modprobe.d/iommu_unsafe_interrupts.conf and kvm.conf with allow_unsafe_interrupts=1 and ignore_msrs=1. These are compatibility settings applied by the script, not universal Windows/macOS requirements; unsafe interrupts relax interrupt-remapping protection.
  • /etc/modprobe.d/blacklist.conf: NVIDIA — nouveau/lbm-nouveau; AMD — radeon + amdgpu; Intel — i915. These vendor-wide entries may affect other cards using the same driver. The proprietary nvidia module is blocked only through /etc/modprobe.d/proxmenux-nvidia-vfio-blacklist.conf when all host NVIDIA cards are tracked for VFIO.
  • /etc/udev/rules.d/10-proxmenux-vfio-bind.rules + /etc/proxmenux/vfio-bind.bdfs — NVIDIA only. The udev rule sets ATTR{driver_override}="vfio-pci" at PCI ADD for tracked BDFs, including affected IOMMU-group functions. Cards outside those groups can retain the nvidia driver. Per-BDF policy does not split a hardware IOMMU group.
  • AMD only. Attempts a ROM dump from /sys/bus/pci/.../rom or ACPI VFCT into /usr/share/kvm/vbios_<vendor>_<device>.bin. If successful, the VM uses romfile=. A valid dump does not guarantee successful GPU initialization.
  • NVIDIA only. Host NVIDIA services (nvidia-persistenced, nvidia-powerd, nvidia-fabricmanager) are stopped and disabled only when every NVIDIA GPU is assigned to VFIO. With a mixed host they remain active, together with the nvidia module, for the GPU(s) that stay native.
  • update-initramfs -u -k all — only runs if any of the above actually changed.
Step 8

VM config is applied via qm set

The VM config at /etc/pve/qemu-server/<vmid>.conf is updated via qm set (never by direct sed):

# Example — what ends up in the VM config after a GPU + audio passthrough
# (you don't type this, ProxMenux does it for you)

hostpci0: 0000:01:00.0,pcie=1,x-vga=1[,romfile=vbios_1002_15dd.bin]   # GPU video (AMD ROM file named vbios_<vendor>_<device>.bin)
hostpci1: 0000:01:00.1,pcie=1                                    # GPU audio
vga: std

# NVIDIA only — hide the hypervisor from the guest driver (Code 43 fix)
cpu: host,hidden=1,flags=+pcid
args: -cpu 'host,+kvm_pv_unhalt,+kvm_pv_eoi,hv_vendor_id=NV43FIX,kvm=off'

The script adds x-vga=1 for AMD and NVIDIA, not Intel. This describes its configuration policy; it does not establish that every Intel iGPU lacks firmware or that the flag universally causes hangs.

Additional hostpciN lines are appended if the GPU's IOMMU group contains other devices you need to pass together.

Step 9

Reboot if host config was touched

Follow the reboot prompt when host boot or driver settings change, and verify the GPU’s active binding before starting the VM. Saved configuration does not prove it is active. A VM-to-VM reassignment with the correct VFIO state can avoid a host reboot.

Summary screen showing what was changed, followed by a reboot prompt

Vendor-specific notes

NVIDIA

The script retains a legacy Code 43 workaround: hidden=1, vendor ID NV43FIX in args, and kvm=off. It is not a universal requirement for current GeForce drivers: NVIDIA enabled Windows-VM passthrough support in R465. Code 43 can have other causes; verify the actual GPU and driver combination.

Multi-GPU NVIDIA support

Mixed NVIDIA use is supported per BDF. Functions assigned to vfio-pci are tracked by PCI address, not merely a shared vendor:device ID. Cards outside the affected IOMMU groups can keep nvidia and be checked with nvidia-smi. Two cards in the same group are not independently isolated by this policy.

AMD

Some AMD GPUs fail to reset after a VM stops. The assistant checks reported capabilities, not every real restart cycle. vendor-reset supports a limited device list and requires compatible kernel support and early loading; the script does not install it. The Windows RadeonResetBugFix project is another hardware-dependent workaround, not a guaranteed fix for all AMD GPUs.

Intel iGPU

Full Intel iGPU passthrough and SR-IOV are separate workflows. This assistant reserves the full device for one VM and omits x-vga=1. i915-sriov-dkms applies only to supported SR-IOV hardware/kernel combinations; a “UHD 630+” label is not a compatibility rule. Plan alternate host-console access.

Verification

# Replace PCI_ADDRESS and VMID with the actual values.
# Verify the exact PCI address, especially with identical GPU models.
lspci -nnk -s PCI_ADDRESS
# Expected driver: vfio-pci

qm config VMID
qm start VMID
qm status VMID
# Inspect the start task in Proxmox Tasks if startup fails.
# Inside the guest, install a compatible GPU driver and test the application.
# NVIDIA: nvidia-smi; AMD/Intel: the guest driver and application diagnostics.

Troubleshooting

Code 43 in Windows (NVIDIA)

Code 43 is not proof of failed KVM hiding. Inspect qm config VMID | grep -E "cpu|args" (replace VMID) for the script’s hidden=1 and hv_vendor_id=NV43FIX settings, but also check the guest driver, GPU firmware and assignment. Re-running may exit early if the GPU is already assigned.

AMD GPU works once, fails on VM restart

A reset failure is one possible cause. A host reboot or power cycle may restore the device temporarily. Check whether vendor-reset supports this exact GPU and kernel and load it early as its documentation requires; softdep amdgpu pre: vendor-reset alone does not guarantee early loading before VFIO. The Windows RadeonResetBugFix workaround also requires a compatible GPU.

VM stuck booting / GPU not detected

Inspect the selected PCI address with lspci -nnk -s PCI_ADDRESS; expect Kernel driver in use: vfio-pci. Replace PCI_ADDRESS with the real BDF. If the native driver remains, inspect the appropriate binding policy, not only /etc/modprobe.d/blacklist.conf; NVIDIA also uses per-BDF state. Read dmesg | grep vfio. After correcting persistent configuration, rebuild with update-initramfs -u -k all and follow the reboot plan.

Host console goes dark after reboot and I can't SSH in

A dark display does not prove the host is down. If SSH also fails, check network connectivity and whether a network/storage controller was included in the IOMMU group. Recover through IPMI, serial or a recovery environment; inspect the VM config /etc/pve/qemu-server/<vmid>.conf and only revert the relevant assignments and host binding rules. Do not delete unrelated blacklist or VFIO configuration.
# Inspect from a recovered Proxmox host; replace the placeholders.
qm config VMID
lspci -nnk -s PCI_ADDRESS
cat /etc/proxmenux/vfio-bind.bdfs 2>/dev/null
# Review the affected PCI assignments and driver-binding configuration.
# Do not remove entire shared blacklist.conf or vfio.conf files.
# Use ProxMenux Switch GPU Mode to return a GPU to the host driver.
# Review its affected guests and follow the indicated reboot procedure.

Check the install log

Every run writes to /tmp/add_gpu_vm.log. Attach it when asking for help on GitHub.

Reverting manually

Stop the VM and remove only its relevant PCI assignments in Proxmox Hardware, or with the explicit index shown below. Detaching from the VM does not return the device to a native host driver. Use Switch GPU Mode for that separate transition and inspect the affected guests before confirming.

# Replace VMID. Inspect the actual assignment index first.
qm config VMID
# With the VM stopped, remove ONLY the intended entry (hostpci0 is an example).
qm set VMID --delete hostpci0
qm config VMID
# Repeat only for the associated PCI entries you intend to remove.
# This does not change the host's VFIO/native-driver binding.

Related