Ubuntu 18.04: 2 VM, 2 Gpu passthrough

Hello, i was willing to do a dual VM with two GPU (RX480 and GTX660).

I’ve sucessfully done one VM with the RX480 working fine without any problem.

So i was wondering if it was even possible to passthrough two gpu and furthermore two gpu from two differents companies. Since we use amdgpu for AMD and nouveau for NVIDIA.

There is no inherent problem with doing that.

You of course would have to check that the other GPU is also isolated in it’s own IOMMU group, and either run the host system headless while the VMs are on or have a 3rd GPU.

Sorry for the long response time.

So i’ve tried to do that but i don’t have any clue how to do that since i have 2 separate drivers to assign.

And i’m running into the IOMMU group problem since they are tied in the same group so KVM will say that the ressource is already used if i try to use the second vm.
And since i don’t have any idea on how to properly set the right driver for each card the nvidia one can’t be used(no display) because i’ve set the AMD driver.

Up! Anyone?

There are two things to try when cards are in the same IOMMU group.

  1. Is switch which card is in which slot. This may or may not work, it depends on how many slots and cards you have and how your motherboard’s groups are setup.

  2. Recompile the kernel with the ACS patch, then put pcie_acs_override=downstream in grub kernel options. Since you are using Ubuntu, there are precompiled binaries available here- https://queuecumber.gitlab.io/linux-acs-override/
    Here is a good article with info- https://heiko-sieger.info/iommu-groups-what-you-need-to-consider/

If i switch the slot of the 480 and 660 i don’t think that is going to change anything.

  1. I could try to put the 660 in the other 16X ports @4X but it will disable all the 1x ports that i have it could work.

  2. That may work.

  3. 1&2 solve one problem but not the second where i don’t know how i can assign amd driver to the 480 and nouveau driver to 660. I suppose i need to make additional file in /etc/modprobe.d :
    -nouveau.conf and amdgpu.conf
    -For vfio_pci.conf i’m not sure at all
    And for the modules in the initramfs no clue for me.

  4. Currently i’m barely at home so i don’t have enough time to try everything so i’m trying to have a solid base before doing anything.

I am trying to understand exactly what it is you are trying to do.
Passing two PCI-E devices to a vm is no big problem, neither is passing one
to one and the other to another VM. However, in neither case would you be able to utilize the GPU’s in the host system, as they both need to be bound to VFIO and not to nouveau or AMDGPU. So if you want both GPU’s to be isolated for use in VM’s you would need to have a third or use integrated graphics in your CPU.

There are some methods where you can unbind a GPU from the host system while running, and rebind it to VFIO, however you would need to reboot to get it working with the host again.

Ok. Read a few more responses here. :slight_smile:

I don’t understand why you need to bind nouveau and AMDGPU for the passthrough. That is something you absolutley don’t need as you wan’t both to be bound by VFIO so that the VM can grab them when they start up.

Do you have a third GPU for use with the host or are you planning to run the host headless? As I said in my previous reply, you won’t be able to use the same GPU in the host and also have it available for the VM at the same time.

My third GPU will be my igpu. Used for Linux.

About nouveau/amdgpu you must specifies them in modules and amdgpu.conf with softdep amdgpu/nouveau that’s why I’m asking.

And then I need to break the iommu group in two because my 2gpu are in the same group. With KVM I got an error telling me that the ressources is already use by the first vm.