ESXI with (PCI) GPU passthrough

Outlaw85

[H]ard|Gawd
Joined
Feb 7, 2012
Messages
1,612
I know this isn't a popular topic but came across this trying to pass a GPU through to my VM for plex. This is not to my credit, I wanted to share if anyone else was struggling with this too.

Issue:
-Enable GPU passthrough in esxi, power on/reboot of VM reboots esxi host
-vm fails to power on at all

Fix:
Advanced VM options (add or edit):
pciPassthru.use64bitMMIO = TRUE
pciPassthru.64bitMMIOSizeGB = 16 (variable depending on your GPU, see the links below for details. I don't know the effect of setting this too high which I did since I just copied what someone else entered.)
pciHole.start = 2048
svga.present = FALSE
svga.autodetect = FALSE (optional, I set mine to FALSE but it doesn't matter if you change this)
hypervisor.cpuid.v0 = FALSE (deprecated 7+. If you add this in 7.x, the vm will not load the GPU correctly. It will detect it but be disabled in device manager)


https://earlruby.org/tag/use64bitmmio/
https://communities.vmware.com/t5/E...assthrough-Quadro-Host-Rebooting/td-p/2228131
 
GPU passthrough or PCI passthrough. GPU requires specific supported GPUs and drivers (nvidia grid).
That said, I'll assume PCI passthrough...
I've only had problems with windows, never rebooting the host. Linux worked fine.
If the host reboots, likely bios/motherboard pci bug.

-----------------------

Here are my notes for installing ubuntu with intel quicksync, on dell wyse 5070, J5005 cpu (less than 15watt plex server).
Only ESX 6.5 works with the 5070, other ones psod.

https://www.sysadminstories.com/2018/08/adding-realtek-8111-driver-to-vsphere.html
https://vibsdepot.v-front.de/wiki/index.php/Net55-r8168

Add-EsxSoftwareDepot "C:\7_KIT\VMW\net55-r8168-8.045a-napi-offline_bundle.zip", "C:\7_KIT\VMW\VMware-ESXi-6.7.0-8169922-depot.zip"

Get-EsxImageProfile
New-EsxImageProfile -CloneProfile ESXi-6.7.0-8169922-standard -name ESXi-6.7.0-8169922-standard-RTL8111 -Vendor Razz
Set-EsxImageProfile -ImageProfile ESXi-6.7.0-8169922-standard-RTL8111 -AcceptanceLevel CommunitySupported

Get-EsxSoftwarePackage | Where {$_.Vendor -eq "Realtek"}
Add-EsxSoftwarePackage -ImageProfile ESXi-6.7.0-8169922-standard-RTL8111 -SoftwarePackage net55-r8168

Export-EsxImageProfile -ImageProfile ESXi-6.7.0-8169922-standard-RTL8111 -ExportToIso -filepath C:\7_KIT\VMW\VMware-ESXi-6.7.0-8169922-RTL8111.iso


-----------------------

Open powershell:
Install-Module -Name VMware.PowerCLI
set-executionpolicy remotesigned
Add-EsxSoftwareDepot "ESXi650-201908001.zip", "net55-r8168-8.045a-napi-offline_bundle.zip"
Get-EsxImageProfile
New-EsxImageProfile -CloneProfile ESXi-6.5.0-20190804001-standard -name ESXi-6.5.0-20190804001-standard-RTL8168 -Vendor RTL
Set-EsxImageProfile -ImageProfile ESXi-6.5.0-20190804001-standard-RTL8168 -AcceptanceLevel CommunitySupported
Get-EsxSoftwarePackage | Where {$_.Vendor -eq "Realtek"}
Add-EsxSoftwarePackage -ImageProfile ESXi-6.5.0-20190804001-standard-RTL8168 -SoftwarePackage net55-r8168
Export-EsxImageProfile -ImageProfile ESXi-6.5.0-20190804001-standard-RTL8168 -ExportToIso -filepath ESXi-6.5.0-20190804001-standard-RTL8168.iso



-------------------------


install minimal ubuntu server
once ssh is working...

pass through igpu, vm advanced set svga to FALSE

apt-get install -y libx264-dev
apt-get install -y libx265-dev
apt-get install -y libva-dev
apt install -y vainfo
apt install -y intel-gpu-tools
apt install -y ocl-icd-libopencl1 beignet-opencl-icd
apt install -y intel-media-va-driver-non-free libmfx1

#old# wget https://github.com/intel/compute-runtime/releases/download/21.49.21786/intel-gmmlib_21.3.3_amd64.deb
#old# wget https://github.com/intel/intel-grap...gc-1.0.9441/intel-igc-core_1.0.9441_amd64.deb
#old# wget https://github.com/intel/intel-grap...-1.0.9441/intel-igc-opencl_1.0.9441_amd64.deb
#old# wget https://github.com/intel/compute-ru....21786/intel-opencl-icd_21.49.21786_amd64.deb
#old# wget https://github.com/intel/compute-ru...1786/intel-level-zero-gpu_1.2.21786_amd64.deb

newer, but there's a reported bug for hdr tone mapping, there is also a fix specific to J5005 / Gemini so I went with new.

wget https://github.com/intel/compute-runtime/releases/download/22.06.22433/intel-gmmlib_22.0.2_amd64.deb
wget https://github.com/intel/intel-grap...-1.0.10183/intel-igc-core_1.0.10183_amd64.deb
wget https://github.com/intel/intel-grap....0.10183/intel-igc-opencl_1.0.10183_amd64.deb
wget https://github.com/intel/compute-ru....22433/intel-opencl-icd_22.06.22433_amd64.deb
wget https://github.com/intel/compute-ru...2433/intel-level-zero-gpu_1.3.22433_amd64.deb
sudo apt install ./*deb

curl https://downloads.plex.tv/plex-keys/PlexSign.key | sudo apt-key add -
echo deb https://downloads.plex.tv/repo/deb public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list
sudo apt update

### Should see in the install message:
### PlexMediaServer install: Intel i915 Hardware: Found

sudo apt install plexmediaserver
sudo systemctl status plexmediaserver

### should see two check marks under transcoding:
Use hardware acceleration when available
Use hardware-accelerated video encoding

### To check that its working (other than cpu usage)
General > Enable Plex Media Server debug logging

cd /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Logs
tail -f Plex\ Media\ Server.log | grep -i hard

administrator@mplex:/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Logs$ tail -f Plex\ Media\ Server.log | grep -i hard
Feb 17, 2022 05:24:56.055 [0x7f52859f6b38] DEBUG - [Transcode] Codecs: hardware transcoding: testing API vaapi
Feb 17, 2022 05:24:56.176 [0x7f52859f6b38] DEBUG - [Transcode] Codecs: hardware transcoding: testing API vaapi
Feb 17, 2022 05:24:56.191 [0x7f52859f6b38] DEBUG - [Transcode] Codecs: hardware transcoding: testing API vaapi
Feb 17, 2022 05:24:56.207 [0x7f52859f6b38] DEBUG - [Transcode] Codecs: hardware transcoding: testing API vaapi
Feb 17, 2022 05:24:56.224 [0x7f52859f6b38] DEBUG - [Transcode] Codecs: hardware transcoding: testing API vaapi
Feb 17, 2022 05:24:56.241 [0x7f52859f6b38] DEBUG - [Transcode] Codecs: hardware transcoding: testing API vaapi
Feb 17, 2022 05:24:56.257 [0x7f52859f6b38] DEBUG - [Transcode] Codecs: hardware transcoding: testing API vaapi
Feb 17, 2022 05:24:56.344 [0x7f5285f11b38] DEBUG - [Transcode] TPU: hardware transcoding: using hardware decode accelerator vaapi
Feb 17, 2022 05:24:56.344 [0x7f5285f11b38] DEBUG - [Transcode] TPU: hardware transcoding: zero-copy support present
Feb 17, 2022 05:24:56.344 [0x7f5285f11b38] DEBUG - [Transcode] TPU: hardware transcoding: using zero-copy transcoding
Feb 17, 2022 05:24:56.345 [0x7f5285f11b38] DEBUG - [Transcode] Codecs: hardware transcoding: testing API vaapi
Feb 17, 2022 05:24:56.362 [0x7f5285f11b38] DEBUG - [Transcode] TPU: hardware transcoding: final decoder: vaapi, final encoder: vaapi
 
I use GPU passthrough on my main desktop under esxi and love it. As mentioned in the first post some modifications are required. When I encountered this it was solved pretty quickly with a Google search as it's not a hard fix.

Similar setups and solutions are available for other hypervisors.

In the second post it says nvidia grid is required. This is inaccurate. Many consumer gpus and pro cards work just fine. Sharing the resources from one GPU to multiple vms is what grid was targeted but there were similar AMD solutions available across a larger range of card.

Amd firepro card are fantastic for support under windows or linux. Nvidia LHR cards do not seem to play nice. Nvidia linux support can require fiddling.

As far as stability I was able to run 3 gaming vms off one workstation and it worked great as far as proformance and reliability. That motherboard was unsupported.

Drivers and passthrough for other consumer motherboard perpetuals can be hit or miss. On my current msi x590 board the ethernet didnt work (no esxi drivers has to buy a super supermicro ethernet card) I can only use 4/5 pcie lanes and the USB passthrough is finicky. Past supermicro based workstations were abit better for compatibility.

Expect some issues you would have to work around but overall I would recommend trying esxi as a desktop or workstation. It's super convenient to be able to spin up vms and assign hardware as needed.
 
GPU passthrough or PCI passthrough. GPU requires specific supported GPUs and drivers (nvidia grid).
That said, I'll assume PCI passthrough...
I've only had problems with windows, never rebooting the host. Linux worked fine.
If the host reboots, likely bios/motherboard pci bug.

-----------------------snip

Yes, sorry. You are correct. PCI passthrough using a GPU. No extra licensing required. Some of the reboot issue I was having seemed to be common for VM misconfigurations, and yes. Windows. I'm not sure how much I want to play with Linux. I dabble but and do some command stuff for work, but not that comfortable.

I use GPU passthrough on my main desktop under esxi and love it. As mentioned in the first post some modifications are required. When I encountered this it was solved pretty quickly with a Google search as it's not a hard fix.

Similar setups and solutions are available for other hypervisors.

In the second post it says nvidia grid is required. This is inaccurate. Many consumer gpus and pro cards work just fine. Sharing the resources from one GPU to multiple vms is what grid was targeted but there were similar AMD solutions available across a larger range of card.

Amd firepro card are fantastic for support under windows or linux. Nvidia LHR cards do not seem to play nice. Nvidia linux support can require fiddling.

As far as stability I was able to run 3 gaming vms off one workstation and it worked great as far as proformance and reliability. That motherboard was unsupported.

Drivers and passthrough for other consumer motherboard perpetuals can be hit or miss. On my current msi x590 board the ethernet didnt work (no esxi drivers has to buy a super supermicro ethernet card) I can only use 4/5 pcie lanes and the USB passthrough is finicky. Past supermicro based workstations were abit better for compatibility.

Expect some issues you would have to work around but overall I would recommend trying esxi as a desktop or workstation. It's super convenient to be able to spin up vms and assign hardware as needed.

Yep, there were a lot of posts coming up with the options to set, but what I was missing or wasn't stated, is the cpuid variable was for older (6.7 or less) esxi versions. I had set this as the comments had stated and everything seemed OK until I tried to transcode and it was all CPU again. Dev Manager showed it disabled for an error. As soon as I removed the cpuid flag, it all seems good now. I'm on HP DL380g8 with esxi 7.0.3 using a Quadro P1000 and Server 2019. Probably some compatibility stuff going on there with the mix of generations.

Just tried another reboot and the host went with it. Found this doc- https://borncity.com/win/2019/07/11/vmware-esxi-hosts-crash-during-vm-shutdown-with-pci-passthrough/
-One of the comments say to add this to the VM config- pciPassthru0.msiEnabled = false
-Tried a few reboots and shutdown/power on. Seems to be OK again.

Also, should have said YMMV.
2012 doesn't seem to want to cooperate
 
Last edited:
Back
Top