Ubuntu – How to set up a KVM/NVidia Passthrough virtual machine for gaming

graphicskvmvirtualizationxen

I've seen a guide or two that seems to be replicated around on the internet on setting up KVM to use passthrough for Nvidia. It seems to require 2 video cards.

Is it possible to do it with 1 video card? I'm trying to see if it's possible to have a gaming machine setup so I don't have to dual boot.

Is this possible? I've heard Xen has a passthrough of their own, but Nvidia doesn't seem to support it on their desktop cards.

I have a GTX 760.

Is it possible to virtualize and get native or near-native performance good enough for modern game gaming?

Best Answer

Ok, I have been on this journey the last few days using Fedora 20, KVM, Xen (all from the Repo, no patches or self-builds) using a GTX260 (for the guest/windows 7) and a cheap GT610 for host/dom0:

  1. With KVM, some nvidia cards work but there are stability issues and your host can crash when rebooting the VM. I gave up on KVM because while it does work, it is far too unstable with my hardware.
  2. I got Xen to passthrough the GTX260, it was very stable and I could shutdown the domU with no weirdness. I installed the nvidia drivers but got a common issue of windows reporting the card wasn't working correctly so I only had basic VGA capability on the guest.

After some reading around, it turns out nvidia cards are pretty crippled when it comes to passthrough. AMD submitted patches to qemu/xen and AMD cards are reportedly working without too many issues on KVM. Quoting from the Xen wiki test cards:

All Radeon HD4xxx, HD6xxx and HD7xxx should work out-of-the-box as secondary adapter with Xen 4.2.1

This means your dom0 boots on one GPU and you passthrough a second GPU to your guest. There is also some support for handing off the primary GPU to a guest but this seems much less straightforward.

On the nvidia front, their high-end professional "Multi-OS" cards to work under Xen and KVM, but this is an artificial limitation placed on home/gamer cards by nvidia. Some people have been modding their cards to report as the equivalent quattro/grid card by replacing resistors on the board. This is possible because the multi-os cards are mostly identical to some higher-end home/gaming cards minus the device ID and some spec differences. Reading the boards, there are/were patches floating around that helped the nvidia case on Windows XP guests, but ... the whole nvidia thing just seems sketchy from a virtualization angle.

There's lots of this around (from the Xen wiki on GPU passthrough):

It's assumed you have a ATI Card you want to passthrough, simply because NVIDIA will only work a) with certain patches and b) with certain Windows Versions

In conclusion, based on what I know, if you want to do passthrough gaming ... go with Xen and AMD cards with a cheap or on-board GPU for dom0 and an additional GPU for the gaming domU. Performance is very high considering the virtualisation overhead too, between 95% and 97% of native framerates in benchmarks.

Good luck!

Some links that help:

  1. http://wiki.xen.org/wiki/XenVGAPassthroughTestedAdapters
  2. https://bbs.archlinux.org/viewtopic.php?id=162768
  3. http://wiki.xen.org/wiki/SecondaryGPUPassthrough
Related Question