foxlet / macOS-Simple-KVM

Tools to set up a quick macOS VM in QEMU, accelerated by KVM.
13.65k stars 1.14k forks source link

GPU device ids #346

Open kaihendry opened 4 years ago

kaihendry commented 4 years ago

How do I work out the id for https://github.com/foxlet/macOS-Simple-KVM/blob/master/docs/guide-passthrough.md#add-kernel-flags ?

[hendry@t14s ~]$ lspci | grep VGA
06:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Renoir (rev d1)

Is it 06:00.0 ?

goshawk22 commented 4 years ago

Use this small script to get all your IOMMU groupings.

#!/bin/bash
shopt -s nullglob
for g in /sys/kernel/iommu_groups/*; do
    echo "IOMMU Group ${g##*/}:"
    for d in $g/devices/*; do
        echo -e "\t$(lspci -nns ${d##*/})"
    done;
done;

It should give you your IDs.

goshawk22 commented 4 years ago

Or just follow the documentation and use lspci -nn | grep "VGA\|Audio" instead of lspci | grep VGA.

kaihendry commented 4 years ago

I see you've updated https://github.com/foxlet/macOS-Simple-KVM/blob/master/docs/guide-passthrough.md#example but I don't quite understand what you've done with 1002:6810. Be good to see a fully worked example for just one GPU. :grimacing:

Can I assume if you have the one card, the next steps are to define it in your /proc/cmdline with iommu=pt amd_iommu=on vfio-pci.ids=1002:6810 and then pass -device vfio-pci,host=26:00.0,bus=port.1,multifunction=on ?

On my T14s, these are the output of the scripts earlier https://s.natalian.org/2020-10-31/t14s-gpu.txt so IIUC my device ID is 1002:1636 with the BDF ID being 06:00.0.

Thank you advance!

goshawk22 commented 4 years ago

If you have only one GPU, it is a lot harder. When you forward the GPU to the virtual machine, you will lose video output for the host operating system and you will have to kill any processes using the display. Here is an example of single GPU passthrough to a windows VM using virtmanager: https://github.com/goshawk22/single-gpu-passthrough.git I'm not sure how to do it with this setup, but you need some kind of script that runs before the VM is turned on and kills any display processes and detatches the GPU. If you plan on doing this long-term or for any serious use, I would recommend getting a cheap GPU like a GT710 as a secondary GPU. EDIT: I just realised that you are using a laptop with integrated graphics! I've never tried this before, so I don't know if it would work. I would try following the steps in the guide above: you will still have to kill all the display processes and you won't be able to add a secondary GPU! It would probably be easier to just use the default virtual GPU - I'm not even sure that MacOS will support vega integrated graphics.

kaihendry commented 4 years ago

Maybe I need to get an eGPU? https://www.carousell.sg/search/egpu Not sure it will work with my AMD T14s, though I do have a spare T480s with Thunderbolt support.

goshawk22 commented 4 years ago

Yes, it might work but at that point you have to consider that it might be better to just get a PC? Using an eGPU like that takes away the protability benefits of a laptop, essentially turning it into a underpowered PC. For $500, you could just get a PC and then add a cheap secondary GPU.

kaihendry commented 4 years ago

Just thought those cursed Optimus setups might be a good option here if you had a laptop. I agree, I should get a PC. Not traveling much, haha.

kaihendry commented 4 years ago

Can I assume to best power FCPX virtualised via macOS-Simple-KVM I need a PC with two Radeons (any particular model I shouldn't go beyond when buying second hand)?

I made a video about macOS-Simple-KVM here: https://youtu.be/As3sDrth74o

And things like

Any comments or suggestions?

goshawk22 commented 4 years ago

It really depends on how much you want to spend. For high end you probably want to go with a AMD Radeon VII but you could just as easily use a RX580. Sapphire branded cards are recommended. I think there is now support for AMD 5000 series cards. For the host operating system, a GT710 would be fine unless you needed something GPU intensive running on the host at the same time. All this needs to do is keep your desktop running. Single GPU passthrough works, but it can be a pain to get set up and doesn't always work as well which is why I would reccomend having a cheap GPU such as the GT710 to drive the display on the host system.