Easiest GPU passthrough guide for Ubuntu

Ryzen IOMMU for multiple VMs with GPU passthrough

https://wiki.archlinux.org/title/PCI_passthrough_via_OVMF

how to passthrough GPU in ubuntu KVM?

Here are the steps to passthrough a GPU on Ubuntu KVM:

  1. Check if your system supports IOMMU: dmesg | grep -e DMAR -e IOMMU
  2. Enable IOMMU in GRUB configuration: sudo nano /etc/default/grub, find the line that starts with GRUB_CMDLINE_LINUX_DEFAULT= and add intel_iommu=on (for Intel CPUs) or amd_iommu=on (for AMD CPUs) to the list of parameters. Save and exit.
  3. Update GRUB: sudo update-grub
  4. Install the necessary packages: sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager ovmf
  5. Reboot your system.
  6. Check if the GPU is detected by running lspci | grep VGA.
  7. Blacklist the GPU driver: echo "blacklist nouveau" | sudo tee /etc/modprobe.d/blacklist-nouveau.conf
  8. Rebuild the initial RAM file system: sudo update-initramfs -u
  9. Reboot your system.
  10. Open Virt-Manager, select the VM you want to passthrough the GPU to and click on "Add Hardware".
  11. Select "PCI Host Device" and choose the GPU you want to passthrough from the list.
  12. Start the VM and install the GPU drivers inside the VM.
  13. Enjoy GPU passthrough on Ubuntu KVM!

For more detailed instructions, you can refer to the link provided in the document.