VGPU


Left: GTX 1070 as Tesla P40, Right: RTX 2080 Ti as Quadro RTX 6000
  1. Flash the drive with DD mode for Proxmox Installation. Hostname should be host1.eliminatrix.com.
  2. Enable apt package manager.
  3. 
    vim /etc/apt/sources.list
    # Add this line
    deb http://download.proxmox.com/debian/pve bullseye pve-no-subscription # proxmox 7 is using bullseye, proxmox 6 is buster
    ####
    vim /etc/apt/sources.list.d/pve-enterprise.list
    # Comment all lines
    ####
    apt update & apt upgrade -y
          
  4. Install dependecies,
  5. 
    apt install -y git build-essential pve-headers dkms jq unzip python3 python3-pip vim
    pip3 install frida
          
  6. Git clone vgpu_unlock.
  7. 
    git clone https://github.com/DualCoder/vgpu_unlock
    chmod -R +x vgpu_unlock
          
  8. Edit grub file,
  9. 
    vim /etc/default/grub
    GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on iommu=pt"
    update-grub
          
  10. Load VFIO modules at boot,
  11. 
    vim /etc/modules
    vfio
    vfio_iommu_type1
    vfio_pci
    vfio_virqfd
          
  12. Update modprobe.d file.
  13. 
    echo "options vfio_iommu_type1 allow_unsafe_interrupts=1" > /etc/modprobe.d/iommu_unsafe_interrupts.conf
    echo "options kvm ignore_msrs=1" > /etc/modprobe.d/kvm.conf
    echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf
    update-initramfs -u
    reboot
    dmesg | grep -e DMAR -e IOMMU
          
  14. Register for Nvidia vGPU free trial driver, and download the zip file,
  15. 
    unzip NVIDIA-GRID-Linux-KVM-460.32.04-460.32.03-461.09.zip
    scp NVIDIA-Linux-x86_64-460.32.04-vgpu-kvm.run root@192.168.1.101:
    chmod +x NVIDIA-Linux-x86_64-460.32.04-vgpu-kvm.run
          
  16. Apply changes to nvidia installer since kernel 5.11 does not accept kernel installation straightaway, then start installation,
  17. 
    ./NVIDIA-Linux-x86_64-460.32.04-vgpu-kvm.run -x
    wget https://raw.githubusercontent.com/rupansh/vgpu_unlock_5.12/master/twelve.patch
    wget https://raw.githubusercontent.com/wvthoog/nvidia_vgpu_proxmox_7/main/nv-caps.patch
    wget https://raw.githubusercontent.com/wvthoog/nvidia_vgpu_proxmox_7/main/nv-frontend.patch
    wget https://raw.githubusercontent.com/wvthoog/nvidia_vgpu_proxmox_7/main/nvidia-vgpu-vfio.patch
    
    cd NVIDIA-Linux-x86_64-460.32.04-vgpu-kvm
    
    patch -p0 < ../twelve.patch
    patch -p0 < ../nv-caps.patch
    patch -p0 < ../nv-frontend.patch
    patch -p0 < ../nvidia-vgpu-vfio.patch
    
    chmod +x nvidia-installer
    ./nvidia-installer --dkms
          
  18. Edit the Nvidia vGPU system services files,
  19. 
    # 1.
    vim /lib/systemd/system/nvidia-vgpud.service
    ExecStart=/root/vgpu_unlock/vgpu_unlock /usr/bin/nvidia-vgpud
    # 2.
    vim /lib/systemd/system/nvidia-vgpu-mgr.service
    ExecStart=/root/vgpu_unlock/vgpu_unlock /usr/bin/nvidia-vgpu-mgr
    # 3.
    systemctl daemon-reload
    # 4.
    vim  /usr/src/nvidia-460.32.04/nvidia/os-interface.c
    #include "/root/vgpu_unlock/vgpu_unlock_hooks.c" // behind #include "nv-time.h"
    # 5.
    vim /usr/src/nvidia-460.32.04/nvidia/nvidia.Kbuild
    ldflags-y += -T /root/vgpu_unlock/kern.ld # at the end
    # 6. 
    ldflags-y += -T /root/vgpu_unlock/kern.ld
    dkms install -m nvidia -v 460.32.04
    reboot
    dmesg|grep -i vgpu # should show 'vGPU unlock patch applied.'
    nvidia-smi # should show
    apt install mdevctl
    mdevctl types # should show different profiles
          
  20. Create vgpu profiles,
  21. 
    touch startup.sh
    chmod +x startup.sh
    vim startup.sh
    ####
    mdevctl start -u 0b5fd3fb-2389-4a22-ba70-52969a26b9d5 -p 0000:09:00.0 -t nvidia-48
    mdevctl start -u 924cfc77-4803-4118-a5f4-bd8de589ddf6 -p 0000:09:00.0 -t nvidia-48
    
    mdevctl define -a -u 0b5fd3fb-2389-4a22-ba70-52969a26b9d5
    mdevctl define -a -u 924cfc77-4803-4118-a5f4-bd8de589ddf6
    ####
    ./startup.sh
    mdevctl list
          
  22. Create new VM with UEFI and Q35, can use multiple snapshot for testing,
  23. 
    vim /etc/pve/qemu-server/100.conf
    ### Add this to the beginning
    args: -device 'vfio-pci,sysfsdev=/sys/bus/mdev/devices/0b5fd3fb-2389-4a22-ba70-52969a26b9d5' -uuid 00000000-0000-0000-0000-000000000100
    ###
    # Also set up sshd and rdp server.
          
  24. Install NVIDIA driver from the same zip file,
  25. 
    scp 462.96_grid_win10_server2016_server2019_64bit_international.exe root@192.168.1.101:
          
  26. After reboot, the proxmox client will show black screen, you can use remmina or rdp client to log in. Then install Parsec.app and VB-AUDIO Cable.
  27. 
          

References


  1. vGPU Software Free 90Days Trial | NVIDIA