2 Gamers, 1 CPU, NO VIRTUALIZATION! | Linux Multiseat with Hardware Accelerated OpenGL+Vulkan

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi i'm his brother and we both wanted to game at the same time but due to crypto mining gpu shortage gpu scalpers everything's too expensive we couldn't afford two computers so this was our solution so we got here is we got one computer and it's got two graphics cards and one of everything else and we're sharing it we're both able to run games at the same time and we're not using virtualization to do it this is not a bad experience at all no pretty good it's running smoothly it's running perfectly smooth i know you've all seen that video two gamers one cpu but that system used virtualization there was an operating system acting as the hypervisor which had its own graphics card probably integrated graphics plus two discrete graphics cards each being passed through to a virtual machine the system was being partitioned discreetly with each virtual machine being a completely separate install of windows with its own memory its own emulated hard disk and its own physical graphics card one user on the system could not use all of the resources at most they could use half but that's not what i'm doing here today what i have is one system running linux both of these users are logged into the same system each of them has their own desktop their own keyboard monitor mouse and to them it's like a separate computer each user in this setup does have access to complete hardware acceleration to one of the graphics cards in the system this works for opengl and it works for vulkan this technique is called linux multi-seat and it's a feature that linux has supported for a long time but in recent years has gotten much easier to implement in this video i'm going to walk through how to set up linux multi-seat with full graphical acceleration for all users the only stipulation here is we need a separate graphics device for each user in this case i'm able to use the integrated vega graphics on my amd apu for this user and i'm able to use my rx 580 for that user so i don't need three graphics cards because i don't have a host and i don't have a hypervisor i don't need to deal with the hassle of pcie passthrough to virtual machines and all of my programs could potentially use all of the ram and the system if they wanted to so let's talk a bit about hardware what hardware am i using today this is my test bench it's really the only system i have that's free you've seen it in some of my other videos like my seven desktops rdp video link up there for that one it's an amd ryzen 5 3400 g which is part of the zen plus family of apus with vega graphics also known as raven ridge it's on asrock b450m micro atx motherboard with 32 gigs of ram and a dual channel configuration in addition to the integrated vega graphics i also have a radeon rx 580 which is a polaris based gpu i've specifically chosen to use all amd graphics cards for this build in theory you should be able to mix between intel and amd however i can't test that to verify according to reports that i've read it's not possible to use this with nvidia and amd mixed although it should work with a pure nvidia or pure amd solution mostly due to the proprietary nature of nvidia's linux drivers so first we're going to go on a trip into the bios make sure all the settings are right here in my particular setup the primary video adapter had to be set to integrated graphics i found on my motherboard with my bios if i didn't set the primary video adapter to integrated graphics then it would disable the onboard graphics entirely which is something we really don't want whatever you set this to is going to be very important later because our primary video adapter has to be our first seat seat number zero if we get that wrong later it'll have problems booting up so now we're going to install ubuntu so for this project i've chosen to install ubuntu 22.04 which is jammy jellyfish as of the filming of this it's still in beta but when this video comes out it should have been fully released i'm going to elect to install this with zfs on root that gives each user their own data set on home directory it also gives us the option to enable deduplication if we want to if you have a bunch of users and they all have their own steam library in their home directory you can deduplicate them with cfs next up is the user i'm going to call myself multi-system so while this installs let me give you a little bit of back story about how i came to this project so i've been using linux for a very long time the first version of linux i ever used was ubuntu 6.06 dapper drake which as the name suggests came out in 2006 back then i was running a phpb server for my friends and i to communicate we had basically no security but the internet was different back then sometime later i found a wikipedia article which had a great graphic graphics showed a 90s era beige computer tower connected to four crt monitors beige keyboards and beige mice and all four of those crt monitors were hooked up to that one computer to say i was impressed with what linux could do as an understatement but back then i was in high school and i couldn't figure out how to set it up but that image of those four beige crt monitors with that one beige tower has stuck in my mind all those years and i knew that someday i wanted to come back and set up a a true multi-seat linux system so as linux has evolved support for multi-seat has gotten both easier and harder back in the day of the beige box there wasn't much hardware acceleration to speak of on a basic desktop video encoding back then was still done in flash if you remember flash so it wouldn't be too unreasonable to connect an x server to every single vga port on the computer or throw in a bunch of pci vga cards if you really wanted to there were also usb options back then and there still are usb 3 video cards now which i might come explore in a future video so now software support in linux with system d has greatly improved the ease of use of multi-user multi-seat systems it's pretty easy now with the mainstream desktop environments and display managers to choose which resources you want to allocate to which seat in my case i'm picking which keyboards which mice and which graphics cards are going to go where and system d and login control just kind of figures that all out it works very well what's harder about doing it now is that 3d acceleration has become very prevalent and it's pretty much an expectation that every desktop has 3d acceleration for video decoding and things like that so that's where the requirement for one graphics card per user comes in the linux developers are concerned about the security implications of allowing more than one seat to have access to the video memory on the same graphics card so we're going to restart into this install then we're going to set up systemd login control in each seat so at this point i'm going to plug in my second monitor i don't have two screen capture devices so you're going to have to bear with me so during the boot process our primary gpu is the one that goes through the initial early stage boot loader at some point in the boot process the ubuntu logo is going to show up on all of the monitors that's a good sign so the login screen showed up on the monitor i'm not screen capturing so i'm sorry now we got our ubuntu desktop so here we go running updates like we always do i'm also going to install openssh server and that's mostly just so i can view radio on top remotely and if we make any really big mistakes we can probably correct them over ssh and i'm using the built-in amd gpu drivers that come with this kernel version and for ubuntu 22 that's kernel 5.15 and they seem to work just fine i am going to install radeon top which is a utility that shows you usage of radeon gpus if i run radio on top right now you can see it found raven on bus zero seven so the pcie address is that starts with a zero seven so one final housekeeping thing we're going to do before we start adding multiple seats is we're going to get rid of wayland so wayland is an alternative desktop protocol to the traditional linux xorg server and it has some benefits but i found it does not work as well with multi-seat yet so we're going to switch back to the xorg server so for gnome based systems we need to edit fc gdm3 custom.conf if we comment out this line that says wayland enable equals false it'll disable wayland and just use xorg so we'll save that now we're going to reboot and once we reboot we should be ready to start adding devices to the second seat so now before we can continue we need to figure out where our gpus are located on the pci bus so we're going to use lspci so we scroll up here so we have a number of devices that start at zero that seems to be the ravenridge root complex then at 01 we have elsmere rx 470 480 570 etc so that's going to be our rx 580 here so pcie address 0100.00 and then there's also hdmi audio also from the rx 580 so the rx 580 is at 01.00.1 for audio scrolling down a bit further we have 07 vga compatible controller so 07.00.0 is our raven 2 vega mobile graphics and the dot one of that is our audio so we're going to pass through the 07 device to one of our seats and the 01 device to our other seat we need to choose which one goes to which seat so like i mentioned earlier whichever graphics card is your primary video device the one that the system boots up with that needs to be attached to seat zero that means that seat zero is going to have our radeon vega graphics from the raven ridge and our second seat is going to have the rx 580 polaris graphics so if i run radio on top and i run heaven we'll see what it does so we can see our utilization on the raven cpu is spiking up to 100 percent if i open a new tab radio on top takes an option dash b which is bus and you give it the first hex digit of the pci bus where the graphics card's on this case one would be our polaris card so our polaris card is showing about four percent load which is not that high and our raven card is being pegged so now we're going to look at all of the hardware available to pass through to more than one seat and we're going to use a tool called login control for this it's part of system d [Applause] so if we ask it to list seats it tells us there's one seat right now and it's called seat zero so our goal is to add a second seat which we're going to call seat one but first we have to figure out what hardware is already attached to seat zero by default all new hardware in the system gets attached to seat zero and we're going to write some rules that change some of these devices to get attached to seat one so here's a list of all the devices we have on seat zero right now some of them are pretty basic power button video bus then we have this pcie 0100 card zero this is going to be our polaris card the rx 580. notice it has this tag on it that says master that means that it's capable of being a master of seat when you create a multi-seat system you need at least one master for the seat to exist if i start adding a bunch of keyboards and mice to seat one it's not going to spawn a new graphics session just for those keyboards and mice there has to be a master of seat which is always a graphical device in this case one of the masters of seats is the 0100 address on the pci bus which is card 0. so the system has randomly chosen the polaris card to be card 0. and associated with that there is also the render d128 and the graphics frame buffer fb1 and a little bit further down there's the same for sound we have card 0 for sound at pci address 0.1 so those are two devices which we're definitely going to want to move over to the other seat because as i said earlier we need to make sure our primary graphics card is used by the first seat seat zero so going down a bit further we can choose the we can choose devices at any level in this tree so we could choose this address here usb 1 which is one of the ports of the usb root hub or we could choose usb 1.5 which in this case is a logotech mx vertical mouse so if we were to pass through usb 1 to our second seat it would include all of the children devices including this logotech mouse and this unicomp keyboard but not the stuff on usb 2 or further now we scroll down a bit farther we found the second graphics card in this case it's called card one now you might think it's tempting to just pass through card one display port four but it won't work it's going to pass through the entire card a little bit further down we got some more usb devices so on usb 3 which is the third port from the usb root hub on the chipset we have the razer black widow keyboard on usb4 we have a generic optical mouse usb 6 has nothing and then we have a third sound card which in this case is card two and this is our high def audio provided by the chipset so if you need headphones one of your users can use the headphones that are built into the chipset the the front panel audio and the rear panel analog audio but the other user has to use hdmi audio through the graphics card and that works completely fine you just don't get a microphone so if you need a microphone for both users you're going to have to use a usb solution for the second user's microphone so just to reference this i'm going to send it to a file so then i can open that file and we can reference it so now that we know we need to pass card 0 which is not our primary graphics card we're going to set that up first so to attach a device to a different seat you call login control attach so we're going to say attach we want to attach it to seat one and we're going to paste in that line we just copied from the text file so it's the path and the sys file system to the device which in this case is pci address 0100 and drm card 0. boom so you can't see it but my second monitor just showed up with a login prompt so now we're going to go back over here and copy the other devices so because we copied this it copies all the children as well we also need render d128 and we need the frame buffer the frame buffer is called graphics fb1 and we need sound so we're again going to copy and paste this entire card now our second user has sound but they don't have a keyboard and a mouse so next up is usb devices as you'll notice here there's things like usb 1 usb 1-5 if we go over here and run lsusb it'll show us what ports everything is on so bus and device are what we need to put into login control so it's easiest if everything is on the same bus and that doesn't necessarily mean one port more than one port on the motherboard may be associated with the same bus so i recommend you take a known device and plug it into each port individually and figure out which bus that is now device numbers are going to be assigned sequentially when when a device is plugged in so if there are two usb ports that share the same bus you can't tell when a device is plugged into one or the other so now i'm going to look at the devices that are already plugged in and see which port they're attached to on the back of the motherboard and from there i'm gonna know which ports on the motherboard share the same bus because we really want one bus for all of the devices for one user so we can pass through that entire bus and then those usb ports will always be given to the same seat so i've decided is bus one is going to be my keyboard and mouse for seat zero you can see both my unicomp keyboard and my logotech receiver are on bus one so i'm going to leave that attached to seat zero which is where it already is the optical mouse is on bus five and the razer black widow is on bus three so i'm going to take bus three and bus five and assign them to the second seat so that he has a keyboard and a mouse if there's any other ports that share bus 3 and bus 5 all of those devices are coming too to make this easier i suggest you buy a usb 3 hub and connect it to two different route ports on your motherboard this way you can plug in devices and you'll know they'll get assigned to the right seat and so that gives us the mouse and we need the keyboard okay so that should be our second seat it should be up and working now the seat should have shown up as soon as we attached the master of seat but you wouldn't have been able to use it now that we've given it a keyboard and mouse and also sound you can you can go ahead and log into a user on that on that seat so to let a user log into that see we need to create another user first and we could do it here or we do it through the command line so if my main user is called multi-system my second user is going to be called subsystem so to get a working gaming system we don't really have to do much else at this point vulcan should be functional as long as the correct mesa version is installed i'm going to launch steam and steam is going to install mesa for me so the first time you're on steam for linux it wants to do a package search and it's going to install the packages it requires including a large portion of mesa opengl and vulcan and that should get you through pretty much all of the games that are supported correctly on steam one quirk i found is that steam for linux stores your game library in the user's home directory as well as almost all of steam itself and that means if you have multiple users using the system you're going to end up downloading the same game more than one time of course if you use zfs you can turn on deduplication and should be able to figure that out but it's still better than having two complete installs of windows for virtual machines so i'm going to log into my steam account and i'm going to hide that from you guys so before i download a game in steam i'm going to turn on deduplication for home directories in zfs so here's all the zfs data sets we get so in ubuntu it creates a pool called rpool which contains two separate data sets for root and user data root is the root file system with several subsystems and it can snapshot these when it does updates user data is where home directories go in this case is one for multi-system one for root the root user and one for subsystem so i'm going to turn on deduplication at the root use our pool user data level so command i'm looking for is sudo zfs set youtube equals on our pool slash user data there we go so if we list the pool with pseudo zpool list we can see it has a d-dupe ratio of one and b-pool is the boot pool it's used by the grub loader not really a concern of ours so now i'm going to download a game on both this session and the other session so i downloaded half-life 2 on both instances just so we can see that this deduplication works so now we've grown a bit and our d-dupe ratio is 1.72 x that means we've saved a huge amount on this 12.9 gigs here so 12.9 gigs for our pool includes the ubuntu system itself so the ddo system was able to work pretty darn effectively in this case so now that we got all this set up let's game on it okay so you gotta sit on the button okay i said on my button you can get through okay now we can both go through all right nice this is not a bad experience at all no pretty good it's running smoothly it's running perfectly smooth oh i'm supposed to catch it what what is this ah how how does one uh get over there so i hope you liked this introduction to multi-seat systems on linux compared to the traditional methods of gpu passthrough and multiple virtual machines this system is much more resource efficient you also don't need to deal with single gpu pass-through or having an extra gpu just to dedicate to the hypervisor of course all of that assumes the games you want to play run on linux but thanks to valve and proton it's getting to be a much bigger list of games that are supported these days gaming on this system is about as you would expect for a vega mobile or rx 580 you get about the performance that those gpus should get now as i said earlier this has been a long time dream of mine to see a multi-user linux system where all the users are connected to the same computer i know in a previous video i was able to do with remote desktop but this is truly a multi-user multi-seat system and it works with 3d applications cad games anything that needs opengl or vulcan of course this is just my first step in the linux multi-seat journey eventually i'd like to be able to share graphics outputs on a single graphics card but currently it's just not that easy to set up of course i'll continue working on it and post another video in the future if i can get it to work as always don't forget to like and subscribe comment down below what you thought of the video or any suggestions you have i also just started a discord server so if you're really interested in home lab and linux go check that out too you
Info
Channel: apalrd's adventures
Views: 34,176
Rating: undefined out of 5
Keywords:
Id: OSodGduWeL0
Channel Id: undefined
Length: 24min 26sec (1466 seconds)
Published: Thu Apr 21 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.