KVM GPU passthrough [SOLVED]

Hello, I have a problem and I would like to get some new opinion on it. I have a Fedora 25 server running on a i7-6700K and GTX1060 computer. I set it up as a VM host following this guide and then this one to create VM.
I even enabled
<kvm>
<hidden state='on'/>
</kvm>

Then I installed Windows 10 and latest GeForce drivers and I could run a steam game.
Next I installed a VM guest Fedora 25 with cuda-8.0 toolkit and drivers. My problem is that nvidia-smi returns
Unable to determine the device handle for GPU 0000:00:07.0: Unknown Error
while lspci | grep NVIDIA returns
00:07.0 VGA compatible controller: NVIDIA Corporation GP106 [GeForce GTX 1060 6GB] (rev a1)
00:08.0 Audio device: NVIDIA Corporation Device 10f1 (rev a1)

I have spent two days on this, googling and reinstalling. I cannot run caffe on GPU without it.
Did anyone have a similar issue?

From what i have read nVidia drivers do not cooperate if they detect they're installed on a VM. Perhaps someone can correct but that was my understanding of it. I have not dug into it because i'm on Team Red. (The one that's not crap)

Yeah, there's a good post that @GrayBoltWolf posted a few weeks back, he goes into detail about getting GPU passthrough working with team green.

Read through this:

About 2/3 down the OP, you'll find some libvirt xml for disabling hyperv and kvm. Use that and you'll be in good hands. I had it working for about a month with my 970.

1 Like

Thank you for the info. I have tried editing it maunally, but it seems it needs to be done via virsh edit . Problem is that I cannot install virsh, because the host OS is using a bridge. It connects to the internet correctly, but dnf and yum do not seem to cooperate with the bridge. This is a networking broblem and I should find a solution easily.

Well I found this out, and the question is now how to bypass this issue. I have found info that this refusal of cooperation is a "unintentional and unfortunate bug". However it has been left unfixed for a long time. Problem is I need team green for GPU acceleration for machine learning and neural nets. Thankfully AMD announced Radeon Instinct GPUs so in the future we might have a opensource alternative.

That sounds like a major problem that you should fix.

That said, let's get back on topic.

If you're using the command line to launch your vm with QEMU, try this argument:

-cpu host,hv_time,kvm=off,hv_vendor_id=null

I am using virt-manager remotely via ssh -X. I will try it tomorrow. Thanks for the command.

Oh, that won't work then.

Just SSH into the machine that's running virt-manager and use virsh edit. on that machine.

1 Like

It works! Once I selved the network issues (bad bridge config on my behalf), I was able to isntall virsh and only added the
<kvm>
<hidden state='on'/>
</kvm>

nad the NVIDIA drivers recognized the card. Thanks for all the help and tips. Hope someone finds this useful.

Perfect! Glad it's all working out.

Most of the time, networking problems with libvirt are due to not having the proper optional deps installed.