4 ms·
Something else that works super nice for gaming on Linux: GPU passthrough (gaming on a VM that has direct access to the GPU). I've been doing this since 2017.
by tarruda 6y ago
Something else that works super nice for gaming on Linux: GPU passthrough (gaming on a VM that has direct access to the GPU).
I've been doing this since 2017. Back then I had built my first desktop computer powered by ryzen 1700 + 2 GPUs.
Creating this setup had some challenges, but after the initial hurdle everything has been working perfectly (I imagine things must be easier nowadays).
Created a windows 10 VM, assigned 4 of my 8 cores, 16 GB of RAM (got 64 on the host) and a GTX 1070. This setup is enough to play pretty much any AAA game with max settings on full HD.
Besides having every game working perfectly, I get another nice side effect: sandboxing. No games (mostly proprietary software) have access to my personal/work files.
- zymhan 6y agoI thoroughly agree, Linux KVM and GPU passthrough is amazing. I was disappointed with USB for guests though, I found it impossible to restore my iPhone via iTunes on a Windows VM, because the USB device wouldn't automatically bind to the VM. Which is something even VirtualBox can do well. But maybe the tech has progressed, or there's a better solution to that issue now.
- RealStickman_ 6y agoI "solved" that issue by getting a pcie usb card and passing that through.
- ghthor 6y agoThis is the best way to connect VR headsets as well.
- RealStickman_ 6y agoTrue, though you'd have to do some research on usb controllers that are supported. I had to do that for my Rift s.
- tarruda 6y agoI can't speak for Apple products, but passing USB devices with libvirt/qemu worked nicely so far for me (devices attach/detach automatically when the VM is powered on/off). My main experience is with a Logitech g933 headset, which requires windows-only software to control certain parts of the device.
- moondev 6y agoDo you run two gpus? Or can you handoff to the VM when it boots and back when you shut down? Mind sharing your libvirt xml or qemu script? I've been meaning to give this a try!
- kbumsik 6y agoDepending on your motherboard you might need two GPUs. In my case I use Proxmox and control VMs through is web GUI.
- tarruda 6y agoThe host GPU is a Radeon rx460, the GTX 1070 is only used by the VM (when the VM is running). Here are the most significant configuration files involved in my setup: https://gist.github.com/tarruda/2ea928b90cdecb6f77c2f9ca65bad95b https://gist.github.com/tarruda/2ea928b90cdecb6f77c2f9ca65ba... Note that modprobe configuration is important, as it assigns stub drivers to the GTX that allows it to be handed on demand to the VM. Note that this is made for a debian 10 system (kernel 4.19), other distributions might have different requirements. As for running the GTX 1070 on the host when the VM is not running, I'm not sure if it is possible.
- metalliqaz 6y agoMan, look at all that config. And this is considered a success story? On Windows it's (1) install steam (2) play. To develop with my headless freebsd dev machine, it's just (1) install ssh (2) install x11 client (3) open term.
- boomboomsubban 6y ago90% of that is just making a virtual machine, the equivalent would be acquiring/assembling your dev machine.
- tarruda 6y agoThat big XML file is just how libvirt represents a VM. If you create a VM using libvirt GUI, most of the XML is generated. I made some tweaks based on level1 forums information, but most of that is auto generated by a GUI.
- m463 6y agodo you do anything special to sandbox the games? I've been wanting to try out linux gaming and this makes it more interesting. I've also been thinking about videoconferencing/etc on linux running in the same manner.
- kbumsik 6y agoI am using Windows VM with GPU passthrough too. If you want it out of the box (well, kinda) I would recommend Proxmox. Proxmox is amazing hypervisor OS. Otherwise you need to study tricky things a lot: QEMU, Kernel configuration for VFIO. Also you may need hardware, especially motherboard that supports VFIO groups well. Fortunatly there are quite big communities like Reddit in this topic. Just google "VFIO"
- m463 6y agoThank you for the pointers. I run proxmox right now, but mostly containers and it's a headless server. I've never thought about running it as a desktop system, which sounds intriguing!
- ro2nie 6y agoWith passthrough you could harness the power of the gpu for a plex vm/container on proxmox to help with transcoding.
- tarruda 6y agoNothing special except what comes by default on debian 10 qemu setup, which I think has SELinux or AppArmor profiles enabled. I had to disable seccomp sandbox because it was causing random host freezes (might have been fixed on newest debian updates though). Maybe it is not perfect sandbox for running malicious code, but surely it is enough to make games and anti cheat systems think they are running on a real computer.