Single GPU Passthrough Tutorial - KVM/VFIO

preview_player
Показать описание
The world's first and world's best video tutorial on single gpu passthrough. Play video games in a Windows VM running on Linux

# LINKS #

# Chapters and Links and Commands by Timestamp#
0:00 Intro
1:14 Update your OS
sudo dnf update
1:37 Installing nvidia drivers
lspci -nnk
sudo dnf install akmod-nvidia xorg-x11-drv-nvidia-cuda
2:37 Install UNIGINE Valley
cd ~/Downloads
chmod a+x UnigineValley
cd Unigine_Valley-1.0
./valley
4:00 Benchmark Results (on Host)
4:16 UEFI/BIOS Settings
Enable "Virtualization" and "VT-d"
4:49 Install Stuff
sudo dnf groupinstall --withoptional virtualization
5:10 Configure Linux
sudo vi /etc/sysconfig/grub
Content to add: intel_iommu=on iommu=pt
add_driver+=" vfio vfio_iommu_type1 vfio_pci vfio_virqfd "
sudo dracut -f --kver `uname -r`
6:24 Verify Linux Setup
lsmod | grep kvm
dmesg | grep -i iommu
cat /proc/cmdline
lspci -nnk
7:30 Downloads
7:46 Create the VM
9:30 Installing Windows
10:00 Virtual Disk Performance
11:39 VM Network Connection
11:55 Remote Display
ip addr
13:42 Install Hook Helper
sudo mkdir -p /etc/libvirt/hooks
sudo chmod +x /etc/libvirt/hooks/qemu
sudo service libvirtd restart
11:14 Writing the Hook Scripts
mkdir -p /etc/libvirt/hooks/qemu.d/win10-vm1-singlegpu/prepare/begin
mkdir -p /etc/libvirt/hooks/qemu.d/win10-vm1-singlegpu/release/end
14:50 Customize Hook Scripts
lspci -nnk
15:45 Test and Fix Hook Scripts
sudo systemctl start sshd
/etc/libvirt/hooks/qemu.d/win10-vm1-singlegpu/prepare/begin
lsmod | grep nv
sudo rmmod nvidia_drm
sudo rmmod nvidia_uvm
sudo rmmod nvidia_modeset
sudo rmmod nvidia
18:53 Add GPU to the VM
19:34 Install GPU Drivers
20:04 Mouse and Keyboard
20:40 Install UNIGINE Valley
21:43 Benchmark Results (on Guest)
21:55 Closing Thoughts
22:27 Bonus Message

# External Links #

# Corrections #
If you're having trouble connecting to the VNC on another computer, try disabling firewalld with the command: systemctl stop firewalld

# My Links #
you can find my other creative endeavors at:
Рекомендации по теме
Комментарии
Автор

I followed this guide with some modifications - because I use Arch, by the way - and it worked out great! Thank you.

ceticobr
Автор

I very rarely comment on videos but I am seriously astonished on how accurate this was for my specific use case and how beginner friendly it was.

dinhero
Автор

I typically don’t comment on YouTube videos but I gotta say, this was a banger. Got mine to work pretty seamlessly. Thanks so much been wanting to do this for a while

wizdomofmark
Автор

VFIO is one of the coolest things ever, but all the information out there always go above my head. Thanks for doing videos on this.

roadrunner
Автор

This guy is very clever.
I started with Windows and became full time Linux.
He is different starts with Linux and boots up Windows to play games.
I am pretty old and not active now and hate black terminal all my life.
Graphic and RAM wad hard to come by and I resorted to dual booting.
I just refurbished my first computer with 1MB video and 4MB RAM.
Beauty of Linux is using minimum resources to maxim use.
SAMBA and network computing was my interest with 14 computer network at home all having less than 500MB RAM and only one with 1 GB.
All disconnected and dismantled and have a tiny Intel NUC.
In passing Steam OS and deck has solved the problem of running windows games in Linux.
Unfortunately I do not have money to buy Steam Deck.
This guys solution is pretty excellent and one need not buy a steam deck.
Thank you.

s.b.asokadissanayake
Автор

1 year later it still works like a charm, thanks mate!

just a heads up: after you have setup your GPU drivers on windows, shut it down and in virtman delete any reference to "Display"
so you dont have problems with nonexistent display being the primary one and "microsoft basic display adapter" showing up in device manager :)

Solodam
Автор

Thanks to your guide and some sweat and tears I've managed to get this working near flawlessly. I carefully edited the hook scripts and it unloaded the drivers and disconnected the pci devices as expected, but the VM never grabbed the card. I added the PCI devices in virt-manager and voila, it works! I can also vnc from in the VM to the host which makes it so much easier to jump around. I rate it's 90% solid apart from random freezing for 3 or so seconds, and audio cutting out. This happens about 10% of the time but considering the success it was totally worth it. Might be a good idea to start messing with the xml to do some cpu pinning and such. Great work and cheers!

slomosapien
Автор

I am now commenting while on the windows VM. Thanks a ton for this tutorial!

TeamUnpro
Автор

I followed your guide on Arch but instead of making a virtual drive I just added my Windows drive (/dev/sda) as path for the disk image. Now I can dual boot and also virtualize the same system!

Thank you so much for the helpful guide

Martan
Автор

I've been searching a straight forward guide like this for years, Thanks a lot, it worked perfectly.

Ongez
Автор

Wow, that's a good one. Simple, clear, efficient. Wonderful.

kgsz
Автор

Oh man, I didn't expect that switching between Linux and Windows would be that seamless. I was really expecting needing to edit configs and then restart my computer just to give Windows my GPU, but this is so much nicer.

burkino
Автор

I’ve been looking into this, so glad I found this video. The other videos you mentioned are also helping me with understanding exactly what is happening and what will and will not work, thanks a lot!

jackets
Автор

Hey man, just want to throw out a complement that you have one of the best linux tutorials b/c of 1 reason: you tell us the command and then tell us what said command is doing. Surprisingly no one really does that well (or as well as you) for an audience such as myself (Linux Novice). Shows that you have a good understanding of how the OS works. Linux for me is like learning a new language, everyone is good at telling me what to say at the correct moment but I don't know what these words mean. May I suggest you make more linux videos - perhaps not even gaming related ones? Simple crap like how do I modify grub without using grub-customizer (which Fedora does not let me use) has already sucked hours out of my life w/ no success. I'm sure you can bang those type of tutorials out quickly - more quickly than the 1K steps involved in GPU passthrough. One feedback I hope you will consider is to better highlight the commands you use. Some of the commands mentioned in this video are displayed on screen than less than a second! Really hard for me to rewind/pause/write down. But even with that, great job again.

mtruo
Автор

The amount of work put into this video is honestly insane. Also the confidence which you explain certain topics with, literally spot on, liked =)

czumpi
Автор

There's an issue when trying to "Switch Display type to Spice->VNC": error: chardev `spicevmc` not supported without spice graphics.
I lost an hour trying to install some spice viewer. The solution is to keep that unchanged, instead add another Display that then can be set to "VNC". Mind to switch port for VNC to 5900 (Default), otherwise Spice will take it and you'll have to manually type "IP:5901".

incredibleviolent
Автор

Wow, the timing for this upload was pretty great. Just watched your last video showing the demo of it after thinking I'd give the whole gpu passthrough VM thing another try.

alacritty
Автор

I can only recommend using virtIO block or virtIO scsi storage from the get go. To get the driver correctly on install (and thus see the drive) you just add a second CDROM device => Then you have one CDROM with the windows install and one with the virtIO drivers. On the screen where you select the destination disk no disk will be shown - but you have the option to load the drivers from the second CD. After that the disk ist shown and you can install directly witht he correct drivers. This saves the hustle of changing it (editing XML) as well as prevent some possible errors.

DolphVS
Автор

Thanks a lot! I followed this tutorial and it worked, I had to make some adjustments and troubleshooting but it worked. Unlike other tutorials this tutorial doesn't involve modifying and patching the GPU ROM or vBIOS which seemed scary. I subbed!

tekratek
Автор

Also, If you plan on using Windows, please consider using Windows 10 LTSC IoT 2021. Not only do you get security updates until 2032 (unlike regular 2025), it comes debloated AND it automatically downloads and installs the drivers for your gpu!

chiptunerat