Jump to content

I made a Powershell script to automate the creation of GPU-P enabled Hyper V VMs

https://github.com/jamesstringerparsec/Easy-GPU-P
 

I work for Parsec (high performance remote desktop app) and I have been following Windows GPU partitioning for a while, being able to share a GPU between multiple VM and Hosts has been my dream forever, NVIDIA GRID is expensive and buying a GPUs per VM is also expensive.
 

If you've used GPU-P before however, it's time consuming, from spinning up a VM, doing some trickery to copy driver files over, get your GPU's GUID and partition it correctly.

My goal with this project to make it as simple as proving an ISO, the name of the GPU you want to partition and what other resources you want to assign the VM - the script takes it from there and build and boot the VM, copy all the drivers and partition the GPU.
 

I needed Windows 11 to be able to do this (new Powershell APIs) so the requirements are Windows 11 on the hyper-v host as well as a Windows 11 ISO, along with an NVIDIA, AMD or Intel consumer GPUs with hardware video encoders (Intel Quicksync, AMD AMF and NVIDIA NVENC). Doesn't work with NVIDIA cards on laptops.
 

I also include Parsec, our remote desktop app which should be a great option for anyone who wants high performance access.
 

I hope to make things even easier over time.

Link to comment
Share on other sites

Link to post
Share on other sites

  • 4 weeks later...
On 11/21/2021 at 6:12 PM, JamesStringer said:

I added Windows 10 support to the tool (20H1 or newer)!  

Hey, 

ty for providing this tool!

 

I am using Windows 10 on host and i am running w11 in the VM. I am sharing my RX 580X. I cant connect to the VM cia parsec though. I am using the free version of parsec and i am logged in on both machines. when trying to connect to the vm it says "host encoder failed to initialize". So i guess my VM cant use the hardware encoder of my RX 580X? How can i fix this problem?

Link to comment
Share on other sites

Link to post
Share on other sites

Could it be that i need a virtual display? or even a physical display connectet to my VM?

 

Edit: I tried installing OBS to check whether i can use hardware encoding in there and it didnt work there too. 

 

Edit 2: on DxDiag in "video compressors"

Spoiler

Host:

  AMDh265Encoder, {5FD65104-A924-4835-AB71-09A223E3E37B}, 0x4, 8, amdh265enc64.dll, 30.00.13037.1003
  AMDh264Encoder, {ADC9BC80-0F41-46C6-AB75-D693D793597D}, 0x4, 8, amdh264enc64.dll, 30.00.13037.1003
  AMDh265Encoder, {5FD65104-A924-4835-AB71-09A223E3E37B}, 0x4, 8, amdh265enc64.dll, 30.00.13037.1003
  AMDh264Encoder, {ADC9BC80-0F41-46C6-AB75-D693D793597D}, 0x4, 8, amdh264enc64.dll, 30.00.13037.1003
  H264 Encoder MFT, {6CA50344-051A-4DED-9779-A43305165E35}, 0x1, mfh264enc.dll, 10.00.19041.0964
  WMVideo8 Encoder MFT, CLSID_CWMVXEncMediaObject, 0x1, wmvxencd.dll, 10.00.19041.0867
  H263 Encoder MFT, {BC47FCFE-98A0-4F27-BB07-698AF24F2B38}, 0x1, mfh263enc.dll, 10.00.19041.0001
  WMVideo9 Encoder MFT, CLSID_CWMV9EncMediaObject, 0x1, wmvencod.dll, 10.00.19041.0001
  Microsoft MPEG-2 Video Encoder MFT, {E6335F02-80B7-4DC4-ADFA-DFE7210D20D5}, 0x2, msmpeg2enc.dll, 10.00.19041.0001
  VP9VideoExtensionEncoder
  HEIFImageExtension

VM:

  DV Video Encoder,0x00200000,0,0,qdv.dll,10.00.22000.0001
  MJPEG Compressor,0x00200000,0,0,quartz.dll,10.00.22000.0001

 

I think I somehow have to get those into my VM?

 

Link to comment
Share on other sites

Link to post
Share on other sites

  • 3 weeks later...

@Saricon Sorry just seen this, seems that the RX580 Isn't supported by GPU-P, there are other users who are also having the failure to encode error.  You can follow the issue on the github Repo.

Link to comment
Share on other sites

Link to post
Share on other sites

Thank you very much! So i read through the issue and the issue linked in there and it really seems to be a hardware limitation. Very sad tbh :(. Do you know whether it is possible to pass through a monitor connected to the GPU being virtualized so you wouldnt need parsec to get an image?

Link to comment
Share on other sites

Link to post
Share on other sites

Just watched the LTT video and I want to give this a shot. Is the process any different for AMD hardware? Would the system use less overhead if the VMs were running on windows server?

Desktop: R9 5900X | 64GB @ 3600mhz | Radeon 6800XT | MSI B550 Mag Mortar WiFi | Fractal Design Meshify Compact | All Noctua | Debian Sid

Laptop: Dell XPS 15 | 12th Gen Intel i7 | 32GB RAM | RTX 3050ti | Pop OS

Proxmox: R7 3700X | 64GB @ 3200mhz | EVGA RTX 3060 12GB | R9 290 | All the flash storage | Dumpster Dive Case | All Noctua

Unraid: R5 3600 | 32GB @ 3200mhz | EVGA GTX 1660 Super | 2x 1TB Crucial P3, 5x 4TB Iron Wolf NAS | 2.5 GB NIC | NZXT H440 | All Noctua

Link to comment
Share on other sites

Link to post
Share on other sites

15 minutes ago, welcome2_themachine said:

Just watched the LTT video and I want to give this a shot. Is the process any different for AMD hardware? Would the system use less overhead if the VMs were running on windows server?

same process for AMD hardware, but you need a RX 5000 or RX 6000 series for it to work (except the 6500XT which won't work due to lack of hardware encoder support).  Windows 11 will offer the best performance and support I believe.  The feature isn't ready or working in Win Server 2022.

Link to comment
Share on other sites

Link to post
Share on other sites

@JamesStringer
ive followed your guide and made a win 10 21h2 vm on a win 10 21h1 host.
i'm able to play some games perfectly (haven benchmark, subnatica BZ & raft, will check more later) but some crash. trying to run league of legend provide a dump file, which checking with WinDbg produces:

Spoiler


Microsoft (R) Windows Debugger Version 10.0.22473.1005 X86
Copyright (c) Microsoft Corporation. All rights reserved.


Loading Dump File [C:\Users\Gamer\AppData\Local\Temp\PKMB3AC.tmp]
User Mini Dump File with Full Memory: Only application data is available

Symbol search path is: srv*
Executable search path is: 
Windows 10 Version 19044 MP (6 procs) Free x86 compatible
Product: WinNt, suite: SingleUserTS
Edition build lab: 19041.1.amd64fre.vb_release.191206-1406
Machine Name:
Debug session time: Wed Jan 12 17:08:28.000 2022 (UTC + 2:00)
System Uptime: 0 days 0:05:25.449
Process Uptime: 0 days 0:00:18.000
............................................................
This dump file has a breakpoint exception stored in it.
The stored exception information can be accessed via .ecxr.
For analysis of this file, run !analyze -v
eax=00000000 ebx=05a41ca8 ecx=b12b3d3b edx=ffffffff esi=05a41c58 edi=05a41c68
eip=77b238fc esp=0383cf08 ebp=0383cf14 iopl=0         nv up ei pl nz na po nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000202
ntdll!NtGetContextThread+0xc:
77b238fc c20800          ret     8
0:000> !analyze -v
*******************************************************************************
*                                                                             *
*                        Exception Analysis                                   *
*                                                                             *
*******************************************************************************

WARNING: Stack overflow detected. The unwound frames are extracted from outside normal stack bounds.
WARNING: Stack overflow detected. The unwound frames are extracted from outside normal stack bounds.
WARNING: Stack overflow detected. The unwound frames are extracted from outside normal stack bounds.

KEY_VALUES_STRING: 1

    Key  : Analysis.CPU.mSec
    Value: 2671

    Key  : Analysis.DebugAnalysisManager
    Value: Create

    Key  : Analysis.Elapsed.mSec
    Value: 7250

    Key  : Analysis.Init.CPU.mSec
    Value: 327

    Key  : Analysis.Init.Elapsed.mSec
    Value: 26608

    Key  : Analysis.Memory.CommitPeak.Mb
    Value: 76

    Key  : Timeline.OS.Boot.DeltaSec
    Value: 325

    Key  : Timeline.Process.Start.DeltaSec
    Value: 18

    Key  : WER.OS.Branch
    Value: vb_release

    Key  : WER.OS.Timestamp
    Value: 2019-12-06T14:06:00Z

    Key  : WER.OS.Version
    Value: 10.0.19041.1

    Key  : WER.Process.Version
    Value: 12.1.416.4011


FILE_IN_CAB:  PKMB3AC.tmp

NTGLOBALFLAG:  0

PROCESS_BAM_CURRENT_THROTTLED: 0

PROCESS_BAM_PREVIOUS_THROTTLED: 0

APPLICATION_VERIFIER_FLAGS:  0

CONTEXT:  (.ecxr)
eax=00000001 ebx=00000001 ecx=222fe77f edx=00000001 esi=0383f330 edi=00000007
eip=549765a0 esp=0383f32c ebp=0383f404 iopl=0         nv up ei pl zr na pe nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000246
stub+0x2565a0:
549765a0 cc              int     3
Resetting default scope

EXCEPTION_RECORD:  (.exr -1)
ExceptionAddress: 549765a0 (stub+0x002565a0)
   ExceptionCode: 80000003 (Break instruction exception)
  ExceptionFlags: 00000000
NumberParameters: 1
   Parameter[0]: 00000000

PROCESS_NAME:  League of Legends.exe

ERROR_CODE: (NTSTATUS) 0x80000003 - {EXCEPTION}  Breakpoint  A breakpoint has been reached.

EXCEPTION_CODE_STR:  80000003

EXCEPTION_PARAMETER1:  00000000

STACK_TEXT:  
WARNING: Stack unwind information not available. Following frames may be wrong.
0383f404 550a767e     0383f460 00000001 00000000 stub+0x2565a0
0383f620 550ac3ee     54a9b834 5496330a 0383f628 stub!packman+0x686266
0383f654 549812ae     00000001 00000001 0383fb01 stub!packman+0x68afd6
0383f66c 54976c57     549a5228 549a5328 8145a204 stub+0x2612ae
0383f6ac 54976bb6     54720000 0383fb64 0383f6fc stub+0x256c57
0383f6bc 54976dde     54720000 00000001 0383fb64 stub+0x256bb6
0383f6fc 54976ed7     54720000 00000001 0383fb64 stub+0x256dde
0383f744 77b22996     54720000 00000001 0383fb64 stub+0x256ed7
0383f764 77afdd42     554b324b 54720000 00000001 ntdll!LdrxCallInitRoutine+0x16
0383f7b0 77b01843     00000001 0383fb64 c288db79 ntdll!LdrpCallInitRoutine+0x51
0383f840 77b019b1     03b485a8 03b32df0 03b485a8 ntdll!LdrpInitializeNode+0x135
0383f864 77b019c8     0383f883 77ac261c 77ac2054 ntdll!LdrpInitializeGraphRecurse+0x5d
0383f888 77b5c1d6     0383f9ed c288d9d5 0367c000 ntdll!LdrpInitializeGraphRecurse+0x74
0383faec 77b16431     c288d87d 00000000 00000000 ntdll!LdrpInitializeProcess+0x1dc6
0383fb44 77b16321     00000000 00000000 00000000 ntdll!_LdrpInitialize+0xba
0383fb50 00000000     0383fb64 77ab0000 00000000 ntdll!LdrInitializeThunk+0x11


SYMBOL_NAME:  stub+2565a0

MODULE_NAME: stub

IMAGE_NAME:  stub.dll

STACK_COMMAND:  dt ntdll!LdrpLastDllInitializer BaseDllName ; dt ntdll!LdrpFailureData ; ~0s ; .ecxr ; kb

FAILURE_BUCKET_ID:  BREAKPOINT_80000003_stub.dll!Unknown

OS_VERSION:  10.0.19041.1

BUILDLAB_STR:  vb_release

OSPLATFORM_TYPE:  x86

OSNAME:  Windows 10

FAILURE_ID_HASH:  {14b2372f-1dd2-f9fc-f08c-9ec0d6de704e}

Followup:     MachineOwner
---------


and satisfactory crushes into Unreal engine 5 crush handler with this message:
 

Spoiler

Version: 160628, IsEditor: No, IsPerforceBuild: No, BuildConfiguration: Shipping, Launcher: -, NetMode: -, IsUsingMods: No

Assertion failed: bFoundMatchingDevice [File:D:/ws/SB-210421141322-21c/UE4/Engine/Source/Runtime/Windows/D3D11RHI/Private/Windows/WindowsD3D11Device.cpp] [Line: 1692]

FactoryGame_Core_Win64_Shipping!AssertFailedImplV() [d:\ws\sb-210421141322-21c\ue4\engine\source\runtime\core\private\misc\assertionmacros.cpp:100]
FactoryGame_Core_Win64_Shipping!FDebug::CheckVerifyFailedImpl() [d:\ws\sb-210421141322-21c\ue4\engine\source\runtime\core\private\misc\assertionmacros.cpp:450]
FactoryGame_D3D11RHI_Win64_Shipping!FD3D11DynamicRHI::InitD3DDevice() [d:\ws\sb-210421141322-21c\ue4\engine\source\runtime\windows\d3d11rhi\private\windows\windowsd3d11device.cpp:1692]
FactoryGame_D3D11RHI_Win64_Shipping!FD3D11DynamicRHI::Init() [d:\ws\sb-210421141322-21c\ue4\engine\source\runtime\windows\d3d11rhi\private\windows\windowsd3d11device.cpp:1067]
FactoryGame_RHI_Win64_Shipping!RHIInit() [d:\ws\sb-210421141322-21c\ue4\engine\source\runtime\rhi\private\dynamicrhi.cpp:217]
FactoryGame_Win64_Shipping!FEngineLoop::PreInitPreStartupScreen() [d:\ws\sb-210421141322-21c\ue4\engine\source\runtime\launch\private\launchengineloop.cpp:2637]
FactoryGame_Win64_Shipping!GuardedMain() [d:\ws\sb-210421141322-21c\ue4\engine\source\runtime\launch\private\launch.cpp:127]
FactoryGame_Win64_Shipping!GuardedMainWrapper() [d:\ws\sb-210421141322-21c\ue4\engine\source\runtime\launch\private\windows\launchwindows.cpp:137]
FactoryGame_Win64_Shipping!WinMain() [d:\ws\sb-210421141322-21c\ue4\engine\source\runtime\launch\private\windows\launchwindows.cpp:268]
FactoryGame_Win64_Shipping!__scrt_common_main_seh() [d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
kernel32
ntdll

ofc i will check more games once i have time but do you have any idea what is the cause?
i looked up ntdll in my sys32 and it exists. should i rewrite it with my host ntdll?

 

i have radeon 6800 and ryzen 5600x.
gave the vm 6 out of 12 threads . 16 out of 32 gb ram and up to have the gpu resources.

 

another unrelated question: the 6800 driver(10.0.19041.1) in the vm is the same as the hyper-v driver but not the same version as the 6800 driver on the host machine (30.0.14011.3017). is it because the driver is just a pass through or is it the wrong driver? should i manually update the vm driver? if so, should i do it normally by official download and installation or some other way?

Link to comment
Share on other sites

Link to post
Share on other sites

On 1/9/2022 at 12:28 PM, JamesStringer said:

same process for AMD hardware, but you need a RX 5000 or RX 6000 series for it to work (except the 6500XT which won't work due to lack of hardware encoder support).  Windows 11 will offer the best performance and support I believe.  The feature isn't ready or working in Win Server 2022.

Guide worked flawlessly - I'm now running almost zero latency for valheim, portal 2, borderlands 2 as testers. Is there a way to "resize" the percentage of gpu partitioned to a given VM?

Desktop: R9 5900X | 64GB @ 3600mhz | Radeon 6800XT | MSI B550 Mag Mortar WiFi | Fractal Design Meshify Compact | All Noctua | Debian Sid

Laptop: Dell XPS 15 | 12th Gen Intel i7 | 32GB RAM | RTX 3050ti | Pop OS

Proxmox: R7 3700X | 64GB @ 3200mhz | EVGA RTX 3060 12GB | R9 290 | All the flash storage | Dumpster Dive Case | All Noctua

Unraid: R5 3600 | 32GB @ 3200mhz | EVGA GTX 1660 Super | 2x 1TB Crucial P3, 5x 4TB Iron Wolf NAS | 2.5 GB NIC | NZXT H440 | All Noctua

Link to comment
Share on other sites

Link to post
Share on other sites

  • 1 year later...

This works perfect for new VMs but I have about a dozen that I want to apply the GPU-P to that are existing with lots of various programs on them.  I got your CopyFilesToVM so it updates my existing ones and I also got the Assign-VMGPUPartitionAdapter function working independently but still I get an error 43 on those VMs on the GPU driver but on new ones using your full script it works perfect.  Do you happen to have a script for existing VMs or can you lend some advice?  BTW my GPU is the AMD W6800 Pro.

Thanks

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×