Before you start
- Passthrough on KVM uses VFIO, which needs the CPU's and motherboard's IOMMU (Intel VT-d or AMD-Vi) switched on.
- A device must be bound to
vfio-pcion its node, not held by a host driver. The GPU page says, for each card, whether it is bound to a passthrough driver or still held by the host, and Why not? explains what is in the way and what to change. - A passed-through device belongs to the node it is plugged into, so the VM runs on that node.
Pass a GPU to a VM
- Open GPU. Each card on each node is listed; choose Rescan after adding hardware.
- Shut the VM down: a card is attached at boot, not while the machine runs.
- Choose Assign to VM, pick the Virtual machine and confirm with Assign.
- Start the VM; the whole card is now its own. Detach, with the VM off, gives the card back.
Other PCI devices
Since 2.1, SR-IOV virtual functions, network cards, NVMe drives and any other device bound to vfio-pci on its node can be given to a VM whole, from the same page.
CPU pinning, NUMA and hugepages
Each node reports its topology. A powered-off VM can be pinned to chosen host CPUs, kept on one NUMA node and backed by hugepages, from Performance in the VM's tools.
Limits to know
LimitsWhole-device passthrough only: no vGPU, no time-slicing, no sharing one card between guests. CPU pinning, NUMA and hugepages were tested in 2.1 against a simulation, not yet on hardware.
Go further
The capability behind this guide: KVM Virtual Machine Management. Every console page with its limits: the feature reference. Stuck? Ask the community or get support.