This guide helps you identify your NVIDIA GPU's PCI IDs, enable IOMMU, configure VFIO, and confirm the GPU is detached from the host OS.
Once you’ve successfully followed this guide, you can use a Python script to automatically bind or unbind your NVIDIA GPU from the host system with a simple command-line toggle.
Make it executable and run with sudo:
chmod +x gpu-vfio-toggle.py
sudo ./gpu-vfio-toggle.pyThis saves you from manually editing config files and regenerating initramfs every time.
Your computer must have two GPUs: → a dedicated GPU (e.g. NVIDIA 4070) → and an integrated GPU (iGPU) (like Intel or AMD iGPU)
❗ Without both, GPU passthrough to a VM will not work — the host needs a separate GPU to stay usable.
Before starting, ensure your CPU supports virtualization and that it's enabled in your BIOS.
You must have:
- AMD-V (for AMD CPUs), or
- VT-x (for Intel CPUs)
Run:
lscpu | grep "Virtualization"Expected output:
Virtualization: AMD-V # or "VT-x" for Intel
If you see nothing or it's blank:
- Reboot your machine
- Enter BIOS/UEFI (usually by pressing
F2,Del, orEsc) - Enable SVM Mode (for AMD) or Intel VT-x
Run the following command to list NVIDIA devices with their PCI IDs:
lspci -nn | grep -E "NVIDIA"Example output:
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation AD104 [GeForce RTX 4070 SUPER] [10de:2783] (rev a1)
01:00.1 Audio device [0403]: NVIDIA Corporation AD104 High Definition Audio Controller [10de:22bc] (rev a1)
Extract the PCI IDs from the output. In this example:
10de:2783,10de:22bc
Copy and save these values into a text editor.
sudo nano /etc/default/grubFind the line that starts with:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"Replace it with:
GRUB_CMDLINE_LINUX_DEFAULT="intel_iommu=on iommu=pt vfio-pci.ids=XXXX:XXXX,XXXX:XXXX"XXXX:XXXX,XXXX:XXXX = Your PCI IDs
Remove quiet splash if present.
For AMD users, use
amd_iommu=oninstead ofintel_iommu=on.
sudo grub-mkconfig -o /boot/grub/grub.cfgsudo rebootsudo touch /etc/modprobe.d/vfio.conf
sudo nano /etc/modprobe.d/vfio.confAdd the following content (replace IDs if needed):
options vfio-pci ids=10de:2783,10de:22bc
softdep nvidia pre: vfio-pciArch
sudo mkinitcpio -p linuxFor other non-Arch LinuxOS users, use
sudo update-initramfs -c -k $(uname -r)
sudo rebootRun the following to check kernel drivers in use:
lspci -k | grep -E "vfio-pci|NVIDIA"Expected output snippet:
Kernel driver in use: vfio-pci
Kernel driver in use: vfio-pci