So, someone figured out how to unlock vGPU for consumer nvidia GPUs:
Unfortunately this requires some patching to the proprietary driver, nothing crazy, just need to include a file on the available dkms source. I wonder if anyone knows how this could be made to work on NixOS?
For those who do not know, vGPU allows you to share a single host GPU with several virtual machines, effectively allowing for a really nice Windows VM situation for games and such, with near-native performace, without needing to dedicate a separate GPU to Linux! NixOS seems great for this because someone could make some option like
graphics.vgpu.enable and it’d all be set up automatically
Looks like someone would have to package the Nvidia GRID driver first, which I don’t know would even be possible, since I think it requires a paid license to even use. Could be wrong though.
I was able to get this working on my own machine, and packaged it up into a NixOS module at GitHub - danielfullmer/nixos-nvidia-vgpu: NixOS NVIDIA vGPU Module, in case it’s useful for anyone else to get started.
It should be usable in NixOS by adding the following to your configuration :
imports = [ (builtins.fetchTarball "https://github.com/danielfullmer/nixos-nvidia-vgpu/archive/master.tar.gz") ];
hardware.nvidia.vgpu.enable = true;
hardware.nvidia.vgpu.unlock.enable = true;
(Tested working on NixOS
This module provides the drivers for the host kvm NixOS machine, not the guest VM. (Although it shouldn’t be to difficult to get that to work as well.)
The normal nvidia vgpu-kvm drivers don’t include the ability to use the standard X11 desktop on the host, but this module works around that by hackishly combining and building the host and guest drivers into the same package so that you can use your normal desktop while also providing virtual GPUs to guest VMs.
I was able to get a fairly nice working setup with this + looking glass using my 1080 Ti to play games in a windows VM at near native speeds. The following resource is what I used to set up the vGPU + VM in NixOS: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_virtualization/assembly_managing-nvidia-vgpu-devices_configuring-and-managing-virtualization
You’ll also need to install the corresponding GRID drivers in windows.
While this can be tested to work without a proper license, the guest will be limited in framerate until you obtain one. It should be possible to obtain a 90 day evaluation license from Virtual GPU (vGPU) Software Free 90Days Trial | NVIDIA .
Theoretically the GRID + vGPU KVM drivers could be upstreamed into NixOS if there were users that could maintain it, while the vgpu_unlock and driver merging stuff should probably be maintained externally from NixOS.
(edit: Just noticed that it should be
hardware.nvidia.vgpu.* instead of
nvidia.vgpu.*. Fixed in danielfullmer/nixos-config@a6a2473)
(edit 2: Moved to its own repo at GitHub - danielfullmer/nixos-nvidia-vgpu: NixOS NVIDIA vGPU Module)
This has not been working in the latest versions, of nixOS, I made a version that works.
But it doesn’t compile the drivers on the fly, I pre compiled them and for now it’s just grabbing them from my google drive