IGPU output with DGPU,Desktop hybrid graphics, GPU accelerated vm

Hi!
I’ve been thinking of ways to go about gpu accelerated windows virtualization, ive seen a couple examples before of people using an igpu as the host with a dgpu, but im not quite sure how I would go about it.
the general idea is to have either:
A. display output is run through igpu, but all the gpu work is done on a pcie Dgpu, until you start your windows vm, in which case your desktop is moved over to the igpu and the windows vm is gpu accelerated
B. the linux desktop is always run on the igpu, except for some apps that need more gpu horsepower in a similar way to how hybrid graphics is done on laptops, but make sure when you start a gpu accelerated vm it properly disconnects from the host and whatever (since no sr-iov, sadge) and see the vm through looking glass

sorry if my wording isnt too clear, looking through
https://wiki.archlinux.org/title/Hybrid_graphics
https://wiki.archlinux.org/title/External_GPU
and doing the things for the usual single gpu passthrough makes me think its possible

the important part for me is not killing the host DE, ive done single gpu passthough before and found that incredibly annoying because the main thing i want to do is have specific games stay in the windows vm, while my browser and discord and everything is in linux

i dont quite have a APU yet, but ill pick up a ryzen 7 5700g on ebay if i see a clear path for this
my current setup is
ryzen 5 3600
amd rx 6700 (non-xt)
32g ddr4 3400 (oc’ed)
asus b550 proart

any good articles or other forum posts linked in the replies would be super helpful, or just knowing what order to put things together in :slightly_smiling_face:

Leaving this here too to maybe clear things up and simplify
Display output would be from igpu
Igpu would be “host”
Dgpu runs games on linux (or ideally the whole desktop for production applications or so I can have av1 decode), and thats passed through to the igpu output

Once windows vm is started, pass dgpu over, igpu runs linux desktop, and use the windows vm through looking glass

I have such a setup with a 7950X and an RTX 3060. Depending on your DE there might be some annoyances (you need to make sure the DE doesn’t latch on to the dGPU and won’t let go). So which DE would you be using?

Also keep in mind all processes using the dGPU on the host will need to be killed to pass it through, so option A won’t really work. Better to go with option B and use switcherooctl or similar to run specific host apps on the dGPU.

The basic steps are

  1. Bind dGPU to vfio on boot
  2. Rebind to amdgpu after launching the DE (to make sure it does not run on dGPU but on the iGPU).
  3. Run apps which need it on the dGPU using switcherooctl.
  4. If you need the VM, exit those apps (you can use lsof to check which processes use the dGPU).
  5. Rebind dGPU to host after exiting the VM.

Some resources that were useful to me when setting this up:

Depending on the distro & DE you use there are some more specifics probably, but this should get you on your way.

1 Like

I’d be using arch/endeavour OS and KDE wayland
DRI_prime or whatever wouldnt be the choice? Interesting.

Thanks for the info!

Also, wouldnt be too hard to make a script that kills any apps running the gpu in linux, rather then them crashing potentially or whatever?

I would usually be pretty good about closing things first but, we all make mistakes

2 Likes

That’s what switcherooctl uses under the hood. But using it directly would be fine too.

Possible, using lsof + kill. What happens (on my system at least) is that the kernel just won’t let you unbind a device that’s in use, so no apps crash. The unbind process will just hang and the VM won’t launch until you kill/close all the apps.

1 Like

KDE wayland is what the second resource I linked uses so that method should work for you, more or less. It does use nvidia but that should not be too different.

3 Likes

Guess I’ll go ahead with picking up a used 5700g and get to cracking, thanks much!

I’ll be sure to post an update (hopefully ) before this post necros

1 Like

Also @quilt , would you happen to know of good resources to bypass anticheat/spoof hardware?
I plan on passing over 6 of the 8 cores I have, could I make it appear to the system that I have a 5600g or whatever? Just curious to whatever works best

(Obv my intention isn’t cheating, its to play games without dealing with windows :roll_eyes: )

Not really. I’m not that much of a gamer (my use case for a windows VM is 80% photo editing 20% offline gaming). I know you can set “kvm=hidden” somewhere in the config, but in general there is kind of a cat and mouse game going on between game studios and VM users. So strategies seem to change continuall. I remember seeing some thereads on the forum you could search for…