Jump to content

Any Guide on Installing Ubuntu VM with GPU passthrough


Recommended Posts

Hi Forum users,
 

I've recently installed Unraid OS on an old PC and I love the value Unraid provides from old hardware. As a NAS server it's working perfectly and using Docker containers is also super easy. One thing that I'm unable to figure out is using my Unraid server to play around with multiple flavors of Linux. I'd like to use an Ubuntu VM as my general use PC for web surfing and programming workstation. I want to pass through my GTX 1060 and use Nvidia drivers to get a more smooth UI experience (and also for building simple deep learning apps) than VNC drivers provide. I've setup my audio and video devices with ACS override so that the Graphics and Sound card are both Nvidia and use the same bus and slot but different "function" nos. However, I'm unable to figure out a way to connect to the VM using some remote access client. I'm using a Macbook to connect to Ubuntu on my Unraid server.

 

I've come across some step by step guides to setup GPU passthrough for a Windows VM, but couldn't find any beginner's guide for using Linux with GPU passthrough.

 

If I create an Ubuntu VM using the VNC drivers, I'm able to connect using the default web based client but the performance is very choppy and I can't get a 4K output or audio working.

 

Any help will be greatly appreciated, I'm attaching my system diagnostics.

tower-diagnostics-20220509-1130.zip

Link to comment

Hi, you attached diagnostics with:

- no passthrough in the vm settings;

- no gtx 1060 installed in the system

 

No way to tell you if something is wrong in the config or not.

 

Anyway, as a general approach, if I were you I:

1- install the matrox g200 in the primary slot

2- install the gtx 1060 in a secondary slot

[3- setup the matrox as primary gpu in bios]

[4- allow unsafe interrupts in unraid]

5- attach to vfio at boot all components of the gpu (use acs override patch if components are in the same iommu group with other devices)

6- reboot

[7- dump the gpu vbios]

8- setup the gpu passthrough of the 1060 in the gui (all components should be passed, audio, video, [usb]), in a q35+ovmf machine, [pass your dumped vbios]

9- switch to the xml view and change bus/slot/functions, so that the gpu in the guest is a multifunction device

 

[...] may be required

 

If you run a linux machine you should see some output on the monitor, probably it will use nouveau drivers, but this depends on the linux distribution. If you want to switch to nvidia drivers refer to specific forums, as installing the nvidia drivers can be a mess.

Edited by ghost82
Link to comment

Hi ghost82,

Thanks for your response. I'm not sure I follow your instructions completely.

1. Sorry, I uploaded an incorrect diagnostics file that I had downloaded from this forum!!! Attaching the right diagnostic file now.

2. I don't have a matrox g200 graphics card, just Intel integrated graphics and GTX 1060. I created the Ubuntu VM with Intel graphics as the primary and GTX 1060 as the secondary. It has successfully started but how do I connect to it? When I right click on the VM, I don't see an option to "remote" to it.

image.thumb.png.b7cc8c4ff546cccb0a9d02731b21185f.png

 

3. I have ACS Override and "Bind to VFIO at Boot" selected for the Nvidia VGA and audio devices. However, I'm unable to dump the gpu vbios using SpaceInvader's script as I'm getting an error.

 

Appreciate your help.

 

zion-diagnostics-20220724-2356.zip

Edited by Rishumacher
forgot attachment
Link to comment
On 7/24/2022 at 3:51 PM, Rishumacher said:

just Intel integrated graphics and GTX 1060

Do you need both gpus in your vm?Leave the igpu for unraid and pass only the 1060 to the vm.

Delete this:

    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </hostdev>

 

Having said that, these are the errors:

1- the 1060 passthrough setup is wrong, replace this:

    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
    </hostdev>

with this:

    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0' multifunction='on'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x1'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x1'/>
    </hostdev>

 

2- Enable unsafe interrupts: Settings -> VM -> change "VFIO allow unsafe interrupts" to Yes, then reboot the server

  • Thanks 1
Link to comment

I'm curious about this topic as well. I was able to install the Nvidia drivers with VNC as GPU1 and the GTX1650 as GPU2. I then make the 1650 the primary and i'm able to RDP to my linux VM via xrdp (once i figured out how to to setup br0) but then the system doesn't see my GTX1650

Edited by GottaGame9000
typo
Link to comment

 

Hi @ghost82,

 

Thanks for your help. Based on your suggestions I think I've made some headway. Here's what I've done.

1) Created a new Ubuntu VM using VNC as the Graphics Card and Network bridge set to br0 (so that I can connect to the VM using an MS RDP client for MAC).

2) The VM started alright and I used VNC remote to install Ubuntu, create a user and then install xrdp using this guide.

3) With VNC still as the graphics card, I'm able to connect using Microsoft RDP client, but the graphics is extremely sluggish.

4) I then changed the graphics card and audio to GTX 1060 based on your guide above (the bus changed from 0x04 to 0x05 for the new VM).

5) With this new config, I got a blank screen when connecting via MS RDP.

6) I amended the XML to add a GPU ROM manually (I extracted the GPU ROM a while ago and it may be incorrect) using this guide.

7) Now the VM starts but I can't connect to it using MS RDP. Even my router page does not detect a new client added and its corresponding ip address.

 

 

Can you suggest how to proceed from here?

Also, for every new VM that I create, is it the normal process to start with VNC -> setup user and xrdp -> then change the graphics card?

 

Thank You.

zion-diagnostics-20220730-1748.zip

Link to comment

It seems your rom file is empty, you didn't dump it correctly. If it's the only gpu in your system you couldn't dump it in linux. Either add another primary gpu and move the 1060 in a secondary slot to dump the vbios, or boot windows and dump it with gpuz (and check if you need to remove the header with a hex editor), or try your luck and download a rom from internet.

 

Edit: reading again, and you have igpu which should be set as primary when you boot unraid. The above is still valid, make sure you have dumped a proper file.

Edited by ghost82
Link to comment

I have a slightly different setup then @Rishumacher but here's what i got and what I accomplished. I've got a i9-9900K (with a iGPU) and a GTX 1650. I initially setup a new Ubuntu VM (using br0) and used VNC to get the latest updates that the OS would fetch and installed xrdp. I then downloaded the VGA Bios for the 1650 from https://www.techpowerup.com/vgabios/ and using the regular gui interface I set the 1650 as the primary for the VM and directed it towards the vBios. I plugged in a spare monitor to the 1650 video out and launched the VM and that worked. Ubuntu saw the 1650 and offered to download the offical drivers and then I tried xrdp. I sorta worked? I don't know why but  I just had a black screen and when I used a native keyboard I passed through to the VM anything I opened using that appeard on the xrdp screen? Anywho I shut down my VM & unplugged my spare monitor and started the VM back up. I was able to xrdp again, but this time I got a desktop interface (its not the normal one I get when I natively use the VM???). It works, but the performance is awful. Very choppy and I couldn't adjust the resolution or refresh rate. I'll see if I have to mess with any xrdp settings or something to fix that

Link to comment

Here's what I found

 

Improve xrdp preformance
edit /etc/xrdp/xrdp.ini
    "max_bpp=25" and change to max_bpp=128
    "crypt_level=high" and changed to "crypt_level=none"
reboot

 

There was a few other ideas about tweaking the desktop environment or using RemoteFX features. Idk. its a lot smoother now, but its still capped to 50hz

Link to comment

Hi @ghost82,

 

Thanks for pin pointing the error. Unfortunately I've correcting the ROM issue multiple times with no success. I've downloaded the ROM for my graphics card techpowerup and removed the Nvidia header based on instructions in SpaceinvaderOne's tutorial but get the same result (VM starts, blank screen, IP cannot be found on router). I've tried to dump vbios using Spaceinvader One's user script, but I'm getting rom: input/output error like many users have reported.

Moreover, I didn't realise that attaching GPU to vfio will make in unavailable to Docker and I need my Nvidia GPU to run deep learning docker containers.

So, I'll abandon this approach and instead want to setup an Ubuntu VM using igpu that can be used as a daily desktop and not have choppy performance like the default VNC card.

Would you be able to guide me in doing that?

 

 

Appreciate your help.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...