给白羽玩。
验证 GPU 驱动程序安装
验证是否已安装 GPU 设备:Get-PnpDevice -FriendlyName "<device-friendly-name>"
如
Get-PnpDevice -FriendlyName "NVIDIA GeForce RTX 4090"
列出支持 GPU 分区的 GPU 来验证主机服务器是否安装了所需的 GPU 适配器:
Get-VMHostPartitionableGpu | FL Name,ValidPartitionCounts

记住其中所需 GPU 的
Name
和 ValidPartitionCounts
配置 GPU 分区计数
将 GPU-name 替换为Name
值,将 partition-count 替换为ValidPartitionCounts
值中支持的计数之一,下同:Set-VMHostPartitionableGpu -Name "<GPU-name>" -PartitionCount <partition-count>
如
Set-VMHostPartitionableGpu -Name "\\?\PCI#VEN_10DE&DEV_2684&SUBSYS_167C10DE&REV_A1#4&250acbd0&0&0009#{064092b3-625e-43bf-9eb5-dc845897dd59}\GPUPARAV" -PartitionCount 32
运行以查看分区计数是否正确设置:
Get-VMHostPartitionableGpu | FL Name,ValidPartitionCounts,PartitionCount
将 GPU 分区分配到虚拟机
在Hyper-v的操作界面禁用要分配虚拟化的虚拟机的检查点,替换vm-name
为虚拟机名,下同其实如果确认没分配过虚拟GPU这个指令不用执行Remove-VMGpuPartitionAdapter -VMName <vm-name>
分配分区
Add-VMGpuPartitionAdapter -VMName <vm-name> -InstancePath <GPU-name>
Win10没办法用这个指令,并且无法指定路径,但是Win10可以用的指令我忘了
你只能把所有GPU都禁用掉,保证自己要共享的GPU是最高优先级,要不然只会共享优先级最高的GPU,一般来说有核显的是核显,没核显的按照PCIE插槽顺序共享GPU
好了,注意事项就没了!
参考文献: