https://wiki.installgentoo.com/index.php?title=GPU_Passthrough&feed=atom&action=historyGPU Passthrough - Revision history2024-03-29T07:47:10ZRevision history for this page on the wikiMediaWiki 1.31.1https://wiki.installgentoo.com/index.php?title=GPU_Passthrough&diff=53447&oldid=prevNon.relevantsavant: /* 0: Pretext */2023-06-09T14:54:29Z<p><span dir="auto"><span class="autocomment">0: Pretext</span></span></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">Revision as of 14:54, 9 June 2023</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== 0: Pretext ==</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== 0: Pretext ==</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>This Setup requires 2 Graphic Cards (<del class="diffchange diffchange-inline">1ntegrated </del>and one <del class="diffchange diffchange-inline">internal PCI Graphicscard </del>- or - two <del class="diffchange diffchange-inline">internal PCI Graphic Cards) Also I am </del>using <del class="diffchange diffchange-inline">and </del>AMD CPU, remember to use the equivalents if you have an intel CPU. Also the Sound setup is for Pulseaudio.</div></td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>This Setup requires 2 Graphic Cards<ins class="diffchange diffchange-inline">. 1 integrated </ins>(<ins class="diffchange diffchange-inline">AMD Ryzen G, or Intel non-f series CPUs for example.) </ins>and one <ins class="diffchange diffchange-inline">dedicated GPU </ins>- or - two <ins class="diffchange diffchange-inline">dedicated GPUs. This page assumes you're </ins>using <ins class="diffchange diffchange-inline">an </ins>AMD CPU, <ins class="diffchange diffchange-inline">so </ins>remember to use the equivalents if you have an intel CPU. Also the Sound setup is for Pulseaudio.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=== Install virt-manager ===</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=== Install virt-manager ===</div></td></tr>
<!-- diff cache key gwiki:diff::1.12:old-52812:rev-53447 -->
</table>Non.relevantsavanthttps://wiki.installgentoo.com/index.php?title=GPU_Passthrough&diff=52812&oldid=prevAnonsauce: Confused about how to add multiple categories, thought I had it right. Now it is.2023-01-02T11:22:43Z<p>Confused about how to add multiple categories, thought I had it right. Now it is.</p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">Revision as of 11:22, 2 January 2023</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l223" >Line 223:</td>
<td colspan="2" class="diff-lineno">Line 223:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Hardware<del class="diffchange diffchange-inline">|</del>HowTo<del class="diffchange diffchange-inline">|</del>Guides]]</div></td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Hardware<ins class="diffchange diffchange-inline">]] [[Category:</ins>HowTo<ins class="diffchange diffchange-inline">]] [[Category:</ins>Guides]]</div></td></tr>
</table>Anonsaucehttps://wiki.installgentoo.com/index.php?title=GPU_Passthrough&diff=52811&oldid=prevAnonsauce: To follow this guide you need 2 GPU's and its setting up something about that, so it must be about Hardware))2023-01-02T11:20:50Z<p>To follow this guide you need 2 GPU's and its setting up something about that, so it must be about Hardware))</p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">Revision as of 11:20, 2 January 2023</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l221" >Line 221:</td>
<td colspan="2" class="diff-lineno">Line 221:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Also remember to replace "anon" with your own username</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Also remember to replace "anon" with your own username</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">[[Category:Hardware|HowTo|Guides]]</ins></div></td></tr>
</table>Anonsaucehttps://wiki.installgentoo.com/index.php?title=GPU_Passthrough&diff=52666&oldid=prevSneak: Sneak moved page GPU Passtrough to GPU Passthrough2022-11-22T15:00:05Z<p>Sneak moved page <a href="/wiki/GPU_Passtrough" class="mw-redirect" title="GPU Passtrough">GPU Passtrough</a> to <a href="/wiki/GPU_Passthrough" title="GPU Passthrough">GPU Passthrough</a></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #222; text-align: center;">Revision as of 15:00, 22 November 2022</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>Sneakhttps://wiki.installgentoo.com/index.php?title=GPU_Passthrough&diff=52540&oldid=prevTinfoil-hat: Created page with "== 0: Pretext == This Setup requires 2 Graphic Cards (1ntegrated and one internal PCI Graphicscard - or - two internal PCI Graphic Cards) Also I am using and AMD CPU, remember..."2022-09-23T21:14:20Z<p>Created page with "== 0: Pretext == This Setup requires 2 Graphic Cards (1ntegrated and one internal PCI Graphicscard - or - two internal PCI Graphic Cards) Also I am using and AMD CPU, remember..."</p>
<p><b>New page</b></p><div>== 0: Pretext ==<br />
This Setup requires 2 Graphic Cards (1ntegrated and one internal PCI Graphicscard - or - two internal PCI Graphic Cards) Also I am using and AMD CPU, remember to use the equivalents if you have an intel CPU. Also the Sound setup is for Pulseaudio.<br />
<br />
=== Install virt-manager ===<br />
<br />
sudo apt-get install virt-manager bridge-utils<br />
<br />
=== Create a Linux Bridge ===<br />
<br />
add the following to <code>/etc/network/interfaces</code><br />
<br />
auto enp4s0<br />
<br />
iface enp4s0 inet dhcp<br />
<br />
add the following to ```/etc/network/interfaces.d/br0```<br />
<br />
# static ip config file for br0 ##<br />
auto br0<br />
iface br0 inet static<br />
address 192.168.178.10<br />
broadcast 192.168.178.255<br />
netmask 255.255.255.0<br />
gateway 192.168.178.1<br />
# If the resolvconf package is installed, you should not edit <br />
# the resolv.conf configuration file manually. Set name server here<br />
dns-nameservers 192.168.178.1<br />
# If you have muliple interfaces such as eth0 and eth1<br />
# bridge_ports eth0 eth1 <br />
bridge_ports enp4s0<br />
bridge_stp off # disable Spanning Tree Protocol<br />
bridge_waitport 0 # no delay before a port becomes available<br />
bridge_fd 0 # no forwarding delay<br />
<br />
== Step 1: Enable IOMMU ==<br />
<br />
edit <code>/etc/default/grub</code> at the line <code>GRUB_CMDLINE_LINUX_DEFAULT</code> so that it reads like<br />
<br />
GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on iommu=pt"<br />
<br />
Then reconfigure Grub<br />
<br />
sudo grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
== Step 2: Tell VFIO we want to pass through the NVIDIA card ==<br />
<br />
lspci -nnk<br />
<br />
In my case the id of the GPU is ```10de:17c8``` and the HDMI sound output is ```10de:0fb0```. Note the part beneath the GPU where it says ```Kernel driver in use: nouveau.```. If everything works correctly that should change by the time we're done. To flag the card for use by VFIO, create the file ```sudo nano /etc/default/grub``` at the line ```GRUB_CMDLINE_LINUX_DEFAULT``` with the contents:<br />
<br />
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash amd_iommu=on iommu=pt kvm.ignore_msrs=1 vfio-pci.ids=10de:17c8,10de:0fb0"<br />
<br />
Then reconfigure Grub<br />
<br />
sudo grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
== Step 3: Create the Windows VM without GPU passthrough ==<br />
<br />
I recommend using <code>virt-manager</code> and setting up a regular Windows 10 VM using the default QXL video card before trying to do any passthrough stuff. When creating the VM, make sure to select "Customize before install" and set the Firmware option to "UEFI". Create the VM and go through the Windows installer until you have a working Windows 10 installation with no GPU passthrough, then shut down the VM.<br />
<br />
== Step 4: Fix the Windows Code 43 error ==<br />
<br />
This error seems to happen because the NVIDIA driver realizes that it's running inside a VM and will disable itself. Since we don't want that we need to "hide" the fact that there's a VM from the driver. KVM has a mechanism for doing that but it's not exposed in virt-manager, so we'll need to edit the XML config for the virtual machine manually. To do that, run:<br />
<br />
sudo virsh edit win10<br />
<br />
where win10 is the name of the VM that you gave when you created it inside virt-manager. You'll need to edit the contents of the <features> tag in the following way:<br />
<br />
Inside the <nowiki><hyperv></nowiki> tag: add the line:<br />
<br />
<vendor_id state='on' value='1234567890ab'/><br />
<br />
(the actual value of the vendor_id is arbitrary, but it should be a 12 digit hex number).<br />
<br />
Inside the <nowiki><kvm></nowiki> tag: add the line:<br />
<br />
<hidden state='on'/><br />
<br />
Inside the <features> tag: add the line:<br />
<br />
<ioapic driver='kvm'/><br />
<br />
The end result should look something like:<br />
<br />
<features><br />
<acpi/><br />
<apic/><br />
<hyperv><br />
<relaxed state='on'/><br />
<vapic state='on'/><br />
<spinlocks state='on' retries='8191'/><br />
<vendor_id state='on' value='1234567890ab'/><br />
</hyperv><br />
<kvm><br />
<hidden state='on'/><br />
</kvm><br />
<vmport state='off'/><br />
<ioapic driver='kvm'/><br />
</features><br />
<br />
If you boot the machine up again, the NVIDIA driver should actually work! Windows will probably default to using the GPU as the primary card, which means that the Windows login prompt will likely appear on the display connected to the video card rather than the QXL display that you can see in virt-manager.<br />
<br />
== Step 5: evdev keyboard and mouse switching ==<br />
<br />
Make sure the first line looks like this:<br />
<br />
<domain type='kvm' id='1' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'><br />
<br />
See usb devices that you want to pass through (usualy the ones with event in the name)<br />
<br />
ls -l /dev/input/by-id/<br />
<br />
edit <code>/etc/libvirt/qemu.conf</code><br />
<br />
user = "anon"<br />
group = "root"<br />
<br />
cgroup_device_acl = [<br />
"/dev/null", "/dev/full", "/dev/zero", <br />
"/dev/random", "/dev/urandom",<br />
"/dev/ptmx", "/dev/kvm", "/dev/kqemu",<br />
"/dev/rtc","/dev/hpet",<br />
"/dev/input/by-id/usb-Dell_Dell_USB_Keyboard-event-kbd",<br />
"/dev/input/by-id/usb-Logitech_USB-PS_2_Optical_Mouse-event-mouse"<br />
]<br />
<br />
paste this in the very first line in xml:<br />
<br />
<domain type='kvm' id='1' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'><br />
<br />
If it doesn’t, replace the first line with that. Next, add the following near the bottom, directly above “</domain>”:<br />
<br />
<qemu:commandline><br />
<qemu:arg value='-object'/><br />
<qemu:arg value='input-linux,id=mouse1,evdev=/dev/input/event4'/><br />
<qemu:arg value='-object'/><br />
<qemu:arg value='input-linux,id=kbd1,evdev=/dev/input/by-id//event3,grab_all=on,repeat=on'/><br />
</qemu:commandline><br />
<br />
== Step 6: switching from PS/2 to VirtIO==<br />
<br />
As with many other technologies, VirtIO has the capacity to improve evdev virtual input devices’ responsiveness. It is not necessary to remove the PS/2 input devices and replace them. Instead, you can simply add VirtIO input devices to the LibVirt XML file, install the guest drivers, and profit! Find the following section of your XML:<br />
<br />
<input type='mouse' bus='ps2'/><br />
<input type='keyboard' bus='ps2'/><br />
<br />
Add VirtIO mouse and keyboard devices, so in the end it looks like so:<br />
<br />
<input type='mouse' bus='virtio'><br />
<address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/><br />
</input><br />
<input type='keyboard' bus='virtio'><br />
<address type='pci' domain='0x0000' bus='0x00' slot='0x0f' function='0x0'/><br />
</input><br />
<input type='mouse' bus='ps2'/><br />
<input type='keyboard' bus='ps2'/><br />
<br />
== Step 7: Patch Apparmor ==<br />
<br />
Edit <code>/etc/apparmor.d/abstractions/libvirt-qemu</code><br />
<br />
paste:<br />
<br />
# Input<br />
/dev/input/* rw,<br />
<br />
=== Setup Audio ===<br />
<br />
in this configuration, we will get the vm sound and pass it on to the host system<br />
open <code>/etc/pulse/daemon.conf</code> and find/add/uncomment the lines and set these values:<br />
<br />
default-sample-rate = 44100<br />
...<br />
alternate-sample-rate = 48000<br />
<br />
== Step 8: use Pulse Audio ==<br />
<br />
Make sure the very first line of the file does read<br />
<br />
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'><br />
<br />
Instead of<br />
<br />
<domain type='kvm'><br />
<br />
Check at the bottom of your config if a line <code><qemu:commandline></code> exists. If yes make sure to add these options:<br />
<br />
<qemu:arg value='-device'/><br />
<qemu:arg value='ich9-intel-hda,bus=pcie.0,addr=0x1b'/><br />
<qemu:arg value='-device'/><br />
<qemu:arg value='hda-micro,audiodev=hda'/><br />
<qemu:arg value='-audiodev'/><br />
<qemu:arg value='pa,id=hda,server=unix:/run/user/1000/pulse/native'/><br />
</qemu:commandline><br />
<br />
In case <code><qemu:commandline></code> is missing, find the line which ends with <code></devices></code><br />
and add the following block afterwards:<br />
<br />
<qemu:commandline><br />
<qemu:arg value='-device'/><br />
<qemu:arg value='ich9-intel-hda,bus=pcie.0,addr=0x1b'/><br />
<qemu:arg value='-device'/><br />
<qemu:arg value='hda-micro,audiodev=hda'/><br />
<qemu:arg value='-audiodev'/><br />
<qemu:arg value='pa,id=hda,server=unix:/run/user/1000/pulse/native'/><br />
</qemu:commandline><br />
<br />
The 1000 in<br />
<br />
server=unix:/run/user/1000/pulse/native<br />
<br />
represents your user-id, 1000 is the default (one user) Id.<br />
<br />
Open the apparmor libvirt abstractions file <code>/etc/apparmor.d/abstractions/libvirt-qemu</code> and append the following:<br />
<br />
/etc/pulse/client.conf.d/ r,<br />
/etc/pulse/client.conf.d/* r,<br />
/run/user/1000/pulse/native rw,<br />
/home/your-username/.config/pulse/* r,<br />
/home/your-username/.config/pulse/cookie k,<br />
<br />
Also remember to replace "anon" with your own username</div>Tinfoil-hat