Setting Up GPU Passthrough on Fedora with 2 GPUs

I have 2 GPUs. FIrst one is AMD, and I am adding a second one, NVIDIA. It was already running with AMD so all the drivers were installed. No drivers are installed for NVIDIA. NVIDIA will be used in the VM environment only.

Install Qemu/KVM

TODO

Enable IOMMU (both in BIOS and Kernel)

In kernel, you can enable it using this command line argument:

> sudo vim /etc/default/grub
GRUB_CMDLINE_LINUX="... intel_iommu=on" # edit this line and add this new flag
> sudo grub2-mkconfig -o /boot/grub2/grub.cfg # update with the changes
> sudo reboot

Detach the Second GPU from the Host

> virsh nodedev-list # list devices you'd like to detach
> lspci # also you can get numbers here to match with the above command's output

# now attach all relevant devices
> virsh nodedev-detach  pci_0000_03_00_0 
> virsh nodedev-detach  pci_0000_03_00_1

Creating VM

1. Create the machine
2. Now "Add Hardware"
3. Add the required PCI device

References

[1] https://unix.stackexchange.com/questions/546572/virt-manager-kvm-is-not-available
[2] https://discussion.fedoraproject.org/t/libvirtd-stop-responding-after-some-time/84324/2
[3] https://discussion.fedoraproject.org/t/virtual-machine-manager-showing-qemu-kvm-connecting/83961/14
[4] https://discussion.fedoraproject.org/t/virtual-machine-manager-showing-qemu-kvm-connecting/83961
[5] https://gist.github.com/paul-vd/5328d8eb2c626dff36ee143da2e85179
[6] https://forum.level1techs.com/t/fedora-33-ultimiate-vfio-guide-for-2020-2021-wip/163814
[7] https://forums.rockylinux.org/t/rocky-9-1-adding-intel-iommu-on-to-kernel/9747/3
[8] https://www.reddit.com/r/VFIO/comments/qctw7h/detach_nvidia_gpu_without_stopping_graphic_session/

Leave a Reply

Your email address will not be published. Required fields are marked *