Easy-GPU-PV icon indicating copy to clipboard operation
Easy-GPU-PV copied to clipboard

How to verify the percentage of GPU allocation?

Open ikun-404 opened this issue 2 years ago • 10 comments

Hello, I have a question. When I adjust the parameter "gpuresourceallocationpercentage = 50", using graphics rendering in VM, 3D can occupy 100% instead of 50%. Why? How to verify that the VM occupies 50%? 123

ikun-404 avatar Mar 22 '22 07:03 ikun-404

Looking at the script it seems that the allocation percentage is just a minimum. So a better way of thinking about the GPU resource allocation is that if your host is hogging the GPU, your guest with 50% allocation will still have 50% VRAM, compute, encode and decode. However if your host is doing nothing and it appears that it would go above 50%.

FlyGuyGo avatar Mar 23 '22 00:03 FlyGuyGo

This is what the script is actually doing to split the GPU.

    Set-VMGpuPartitionAdapter -VMName $VMName -MinPartitionVRAM ([math]::round($(1000000000 / $devider))) -MaxPartitionVRAM ([math]::round($(1000000000 / $devider))) -OptimalPartitionVRAM ([math]::round($(1000000000 / $devider)))
    Set-VMGPUPartitionAdapter -VMName $VMName -MinPartitionEncode ([math]::round($(18446744073709551615 / $devider))) -MaxPartitionEncode ([math]::round($(18446744073709551615 / $devider))) -OptimalPartitionEncode ([math]::round($(18446744073709551615 / $devider)))
    Set-VMGpuPartitionAdapter -VMName $VMName -MinPartitionDecode ([math]::round($(1000000000 / $devider))) -MaxPartitionDecode ([math]::round($(1000000000 / $devider))) -OptimalPartitionDecode ([math]::round($(1000000000 / $devider)))
    Set-VMGpuPartitionAdapter -VMName $VMName -MinPartitionCompute ([math]::round($(1000000000 / $devider))) -MaxPartitionCompute ([math]::round($(1000000000 / $devider))) -OptimalPartitionCompute ([math]::round($(1000000000 / $devider)))

FlyGuyGo avatar Mar 23 '22 00:03 FlyGuyGo

Thank you for your reply in your busy schedule. When the host is not doing anything, can the VM be adjusted to no more than 50% or fixed at 50%? Is there any way, thank you very much

ikun-404 avatar Mar 23 '22 03:03 ikun-404

Thank you for your reply in your busy schedule. When the host is not doing anything, can the VM be adjusted to no more than 50% or fixed at 50%? Is there any way, thank you very much

Actually, I think I was partially wrong. Upon a second look of the snippet I pulled, there is a part that assigns a maximum as well minimum. So it does appear to be a 50/50 split.

As for how to confirm the split is working… Look in the task manager of the guest machine and see if it shows the max dedicated GPU memory as being half of what your card has.

FlyGuyGo avatar Mar 23 '22 07:03 FlyGuyGo

Thank you for your reply in your busy schedule. When the host is not doing anything, can the VM be adjusted to no more than 50% or fixed at 50%? Is there any way, thank you very much

Actually, I think I was partially wrong. Upon a second look of the snippet I pulled, there is a part that assigns a maximum as well minimum. So it does appear to be a 50/50 split.

As for how to confirm the split is working… Look in the task manager of the guest machine and see if it shows the max dedicated GPU memory as being half of what your card has.

Thanks very much! GPU information cannot be displayed in the guest machine task manager.The picture above is the host GPU information Or the driver needs to be installed?I don't think so All right! The script is really very practical!!! Thank you again for you answer!

ikun-404 avatar Mar 23 '22 09:03 ikun-404

Thank you for your reply in your busy schedule. When the host is not doing anything, can the VM be adjusted to no more than 50% or fixed at 50%? Is there any way, thank you very much

Actually, I think I was partially wrong. Upon a second look of the snippet I pulled, there is a part that assigns a maximum as well minimum. So it does appear to be a 50/50 split. As for how to confirm the split is working… Look in the task manager of the guest machine and see if it shows the max dedicated GPU memory as being half of what your card has.

Thanks very much! GPU information cannot be displayed in the guest machine task manager.The picture above is the host GPU information Or the driver needs to be installed?I don't think so All right! The script is really very practical!!! Thank you again for you answer!

In that case you could use a program such as MSI Afterburner to monitor performance stats such a VRAM usage and FPS in the guest VM.

FlyGuyGo avatar Mar 23 '22 16:03 FlyGuyGo

Thank you for your reply in your busy schedule. When the host is not doing anything, can the VM be adjusted to no more than 50% or fixed at 50%? Is there any way, thank you very much

Actually, I think I was partially wrong. Upon a second look of the snippet I pulled, there is a part that assigns a maximum as well minimum. So it does appear to be a 50/50 split. As for how to confirm the split is working… Look in the task manager of the guest machine and see if it shows the max dedicated GPU memory as being half of what your card has.

Thanks very much! GPU information cannot be displayed in the guest machine task manager.The picture above is the host GPU information Or the driver needs to be installed?I don't think so All right! The script is really very practical!!! Thank you again for you answer!

In that case you could use a program such as MSI Afterburner to monitor performance stats such a VRAM usage and FPS in the guest VM.

Ok,I trying

ikun-404 avatar Mar 24 '22 01:03 ikun-404

This is what the script is actually doing to split the GPU.

    Set-VMGpuPartitionAdapter -VMName $VMName -MinPartitionVRAM ([math]::round($(1000000000 / $devider))) -MaxPartitionVRAM ([math]::round($(1000000000 / $devider))) -OptimalPartitionVRAM ([math]::round($(1000000000 / $devider)))
    Set-VMGPUPartitionAdapter -VMName $VMName -MinPartitionEncode ([math]::round($(18446744073709551615 / $devider))) -MaxPartitionEncode ([math]::round($(18446744073709551615 / $devider))) -OptimalPartitionEncode ([math]::round($(18446744073709551615 / $devider)))
    Set-VMGpuPartitionAdapter -VMName $VMName -MinPartitionDecode ([math]::round($(1000000000 / $devider))) -MaxPartitionDecode ([math]::round($(1000000000 / $devider))) -OptimalPartitionDecode ([math]::round($(1000000000 / $devider)))
    Set-VMGpuPartitionAdapter -VMName $VMName -MinPartitionCompute ([math]::round($(1000000000 / $devider))) -MaxPartitionCompute ([math]::round($(1000000000 / $devider))) -OptimalPartitionCompute ([math]::round($(1000000000 / $devider)))

idk if i suck at math or not. but if you set GPUResourceAllocationPercentage to "50" and $devider is "100 / $GPUResourceAllocationPercentage", and vram is set to "1000000000 / $devider" then, your only giving the VM half a Gigabyte of Vram or 500MB. i feel like that should be mentioned somewhere. i assumed 50 was giving the VGPU 50% of my whole gpu. which has 16GB of vram

pharrowboy avatar May 18 '22 05:05 pharrowboy

I was curious about these values as well. It seems like these numbers are just hard coded in all the examples I find. But it seems to me like I should have to actually see what numbers my GPU puts out and do the math from there. I think the powershell command of "get partitionable GPU" (paraphrase, can't remember the syntax and I'm on mobile at the moment) prints these values out. But that's really a half-statement-half-question coming from me since I'm not experienced with Powershell. Lol

euroclydon37 avatar Apr 08 '23 18:04 euroclydon37

The 1000000000 seems to be standard for all GPUs, and represent 100% of resources. For example, here is a printout of my RTX 3090:

Get-WmiObject -Class "Msvm_PartitionableGpu" -ComputerName $env:COMPUTERNAME -Namespace "ROOT\virtualization\v2"

TotalCompute : 1000000000 TotalDecode : 1000000000 TotalEncode : 18446744073709551615 TotalVRAM : 1000000000

And here is a printout of a Quadro P600, a vastly different card:

TotalCompute : 1000000000 TotalDecode : 1000000000 TotalEncode : 18446744073709551615 TotalVRAM : 1000000000

As far as I can tell, per Microsoft's documentation, some cards allow you to change the partition counts, but so far all the cards I tested, it's fixed at 32. You can verify if you have more options with this command

Get-VMHostPartitionableGpu | FL Name,ValidPartitionCounts

I have not found a reliable way to verify this yet, but in theory, if you want to test and report back, it's fairly easily to manipulate the parameters:

$VMname = "name of your vm"
Remove-VMGpuPartitionAdapter -VMName $VMname
Add-VMGpuPartitionAdapter -VMName $VMName
$GPUResourceAllocationPercentage = value you want to allocate (e.g. 30 for 30% of gpu)
$devider = [math]::round($(100 / $GPUResourceAllocationPercentage),2)

Then run the below to re-set the parameters based on your allocation above.

    Set-VMGpuPartitionAdapter -VMName $VMName -MinPartitionVRAM ([math]::round($(1000000000 / $devider))) -MaxPartitionVRAM ([math]::round($(1000000000 / $devider))) -OptimalPartitionVRAM ([math]::round($(1000000000 / $devider)))
    Set-VMGPUPartitionAdapter -VMName $VMName -MinPartitionEncode ([math]::round($(18446744073709551615 / $devider))) -MaxPartitionEncode ([math]::round($(18446744073709551615 / $devider))) -OptimalPartitionEncode ([math]::round($(18446744073709551615 / $devider)))
    Set-VMGpuPartitionAdapter -VMName $VMName -MinPartitionDecode ([math]::round($(1000000000 / $devider))) -MaxPartitionDecode ([math]::round($(1000000000 / $devider))) -OptimalPartitionDecode ([math]::round($(1000000000 / $devider)))
    Set-VMGpuPartitionAdapter -VMName $VMName -MinPartitionCompute ([math]::round($(1000000000 / $devider))) -MaxPartitionCompute ([math]::round($(1000000000 / $devider))) -OptimalPartitionCompute ([math]::round($(1000000000 / $devider)))

cfelicio avatar Jul 28 '24 15:07 cfelicio