Askannz / optimus-manager

A Linux program to handle GPU switching on Optimus laptops.
MIT License
2.27k stars 165 forks source link

Switch to vfio #487

Open Maziar123 opened 2 years ago

Maziar123 commented 2 years ago

Hi

Can help me for use optimus-manger when switch to integrated automatically set gpu driver to vfio ??

seems need when logout stop display manager virsh nodedev-detach and connect it to vfio .....

any help or experience .... ?

Askannz commented 2 years ago

I assume this is a feature request but you need to be more specific. What exactly doesn't work with VFIO?

Maziar123 commented 2 years ago

@Askannz

Need some manual Job ...

we need exactly ONE mode same as integrated but with name and work "VFIO"

when switch to this mode nvidia gpu set with vfio driver after logout ....

AP1028 commented 2 years ago

@Askannz Basically, we would like to have a easy method to bind and unbind the dGPU with the vfio-pci driver so that GPU passthrough can be achieved more easily. It would great if there's a mode that is similar to intergrated mode, but with the nvidia GPU loaded with vfio driver instead of powered off, so that dGPU passthrough can be achieved afterward. When I want to use a VM with GPU passthrough, I switch the mode to VFIO and start the VM. The dGPU is then used by the VM and the iGPU used by Arch Linux host . When I turn off the VM, I switch the mode back to hybrid so that I can use both GPU in the host again.

The idea is to perform these steps:

  1. Switch Optimus Manager to Integrated, otherwise modprobe -r nvidia will fail.
  2. Unload NVidia drivers
  3. Detach devices
  4. Load VFIO drivers (Reverse the steps when switching back to hybrid)

Here's a guide that contains everything including the scripts that are used to achieve the functionality. https://github.com/mysteryx93/GPU-Passthrough-with-Optimus-Manager-Guide

I hope this can be directly integrated into optimus-manager as an optional feature so that those who need the functionality can achieve dynamic binding with ease.

Maziar123 commented 2 years ago

@Askannz Basically, we would like to have a easy method to bind and unbind the dGPU with the vfio-pci driver so that GPU passthrough can be achieved more easily. It would great if there's a mode that is similar to intergrated mode, but with the nvidia GPU loaded with vfio driver instead of powered off, so that dGPU passthrough can be achieved afterward. When I want to use a VM with GPU passthrough, I switch the mode to VFIO and start the VM. The dGPU is then used by the VM and the iGPU used by Arch Linux host . When I turn off the VM, I switch the mode back to hybrid so that I can use both GPU in the host again.

The idea is to perform these steps:

1. Switch Optimus Manager to Integrated, otherwise modprobe -r nvidia will fail.

2. Unload NVidia drivers

3. Detach devices

4. Load VFIO drivers
   (Reverse the steps when switching back to hybrid)

Here's a guide that contains everything including the scripts that are used to achieve the functionality. https://github.com/mysteryx93/GPU-Passthrough-with-Optimus-Manager-Guide

I hope this can be directly integrated into optimus-manager as an optional feature so that those who need the functionality can achieve dynamic binding with ease.

note : after 1. (Switch Optimus Manager to Integrated, ....) you must stop display manager and in end return it !

awsms commented 1 year ago

big +1 for this, AFAIK only supergfxctl has VFIO support

Maziar123 commented 12 months ago

But I have several problems with supergfxctl. The optimus-manager is more flexible as a base

awsms commented 12 months ago

But I have several problems with supergfxctl. The optimus-manager is more flexible as a base

I don't use supergfxctl because it doesn't recognize my NVIDIA dGPU. I'm trying to implement vfio on optimus-manager, will see what I end up with