GPU Passthrough Tips

Shortly after seeing Wendell's video on GPU passthrough I tried it myself using my recently build modest computer. Performance has been outstanding, even though I do not have a high thread count and am using a "unsupported" Nvidia card. There are a few things I found a long the way that I found were quite crucial to getting good performance. These are my specs:

  • CPU: i5-6600K @ 4.4 GHz
  • RAM: 16GB @ 2533Hz
  • VIDEO: GTX 970 @ 1.5GHz
  • MOBO: Asrock Z170 extreme4
  • OS: Arch Linux with -zen kernel (also works with official kernel)
  • Monitors: Dual 1920x1080 and 1080x1920

Took me about 1 evening to get passthrough to work following the Arch wiki article here:
https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF

Graphics card

The Nvidia card did not work even when passed trough and the drivers on windows are installed. This is because the nvidia driver detects it is running in a hypervisor and gives "Error 43" in the device panel. Troubeleshooting section on the arch wiki shows you how to lie to the driver and fix this.

You also do not need a second graphics card for linux! Intel iGPU's have become really good recently which is great for us. I use the iGPU on linux to drive both my monitors. You do not have to blacklist the nvidia driver like many people recommend, simply make sure you add vfio-pci modules in mkinitcpio so it loads before the driver it handles it, I also uninstalled the nvidia driver because it is not required on the linux side. (Dont forget to set up hardware acceleration!)

Monitor setup

I have two monitors with the iGPU driving both. SInce my monitors have multiple inputs I have the horizontal monitor also connected to the video card. Switching between the virtual machines is easy using the buttons on the monitor to select input and doesn't require any extra hardware.

Mouse and keyboard passthrough

Many will recommend to have two keyboard or otherwise have some sort of switch. I think this is too complicated and two keyboards is a mess. The complaint with synergy is that it introduces latency. The solution is to run the synergy server on Windows and the client on linux. As such when Windows VM is started, the mouse and keyboard are passed to it and it serves them back to linux so there is no latency in games. When the VM is turned off the mouse and keyboard are handed back to linux so you never have to unplug the keyboard or the mouse. Synergy is open source on linux so it is packaged but for windows the home page seems to want to make you buy it. You can download the official one from the nightly page: https://symless.com/nightly

CPU configuration

After getting it to work I found performance was extremely bad. The mouse lagged when just running synergy to share it between linux and windows and light games also lagged hard. Looking at the windows task manager one could see "system interrupts" filled up the CPU with even light load. Reducing the amount of cores shared with the guest os from 4 to 3 and then 2 decreased it but still hindered performance enough to make games unplayable. At this point I was starting to agree with others online that you need atleast an i7 with more threads or a xeon cpu. Then I tired following the additional CPU pinning method in the arch wiki, pinning each 4 threads to an individual core. Despite what the wiki says regarding pinning, this completely fixed the performance and I have zero issues from sharing all cores. Games run perfectly and CPU benchmarks on Windows handily beat the stock for my CPU as I have an overclock.

Network

I found to get the full 200 mbps of NAT from wifi connected linux machine. As such I have found no need to bridge or do any other advanced set up as I get full performance.

In conclusion I am perfectly happy with the set up and experiencing full native performance having Windows and Linux available to me at full speed at the same time.

2 Likes

Apologies for the necro, but could you expand on this:

Then I tired following the additional CPU pinning method in the arch wiki, pinning each 4 threads to an individual core.

If I am reading this right are you dedicating a single core to the VM and giving it 4 threads? or are you using 4 cores with 4 threads each? I have the same processor so this information would be useful.

I am not sure which part of the wiki you are looking at when you mention “the additional CPU pinning method”. I assume you’re editing the libvirt configuration and not using isolcpus.

this is a 2 year old thread, man.

We have an entire wiki and dozens of newer posts on the subject:

PLEASE search around before doing this.

@kewldude007 @Eden @MisteryAngel

1 Like