vGPU configuration and GPU pass-through using the PowerShell SDK for XenServer 6.2.0 SP1

12:06 PM
vGPU configuration and GPU pass-through using the PowerShell SDK for XenServer 6.2.0 SP1 -

The XenServer 6.2.0 SDK for Service Pack 1 is ideal for developers who want programmatically access new XenServer management features for GPU virtualization (including the new vGPU and GPU pass-through). The five available XenServer SDKs, one for each of C, C #, Java, PowerShell and Python, exposing new XenAPI commands for working with physical GPU (pGPUs), GPU groups, virtual GPU (vGPUs) and types virtual GPU.

The GPU technologies for XenDesktop and XenServer are of course also come with configuration operations and provisioning of rich GUI via XenCenter, XenDesktop and MCS.

during our latest development cycles, we have invested in rewriting XenServer PowerShell API to provide developers and administrators with a chic alternative to using the command line XenServer (CLI) d 'interface. In particular, this interface is proving popular with those looking to automate measurement and on vGPU GPU pass-through configuration and benchmarking or self-test frameworks. The PowerShell API is also a popular choice for XenDesktop and Windows administrators working with XenServer.

The following is a tutorial of a typical case of use vGPU configuration applets using XenServer PowerShell SDK. It may be helpful to read my blog colleague of XenServer If the object model provided GPU as background.

The sample output is provided for a server with both NVIDIA Grid K1 and K2 card installed.

We begin by connecting to the server:

 PS C: > Blog XenServer server -Server -username username password -Password 

the first thing we want probably to check is that the GPU groups exist (these are created automatically once the graphics hardware is installed):

 PS C: > Get-XenGPUGroup | select name_label, GPU_types, allocation_algorithm name_label GPU_types allocation_algorithm ---------- --------- -------------------- Group NVIDIA Corporation GK104GL [GRID K2] GPU {10de / 11bf} depth_first Group NVIDIA GK107GL Corporation [GRID K1] GPU {10de / 0ff2} breadth_first 

the allocation_algorithm is the investment policy for the allocation of virtual machines to the GPU to achieve either maximum density by placing as many virtual machines as possible on the same GPU (depth_first) or maximum performance by placing virtual machines on as many as possible GPU (breadth_first). For example, the following command sets the allocation_algorithm to achieve maximum performance:

 PS C: > Get-XenGPUGroup | Set-XenGPUGroup -AllocationAlgorithm breadth_first PS C: > Get-XenGPUGroup | select name_label, GPU_types, allocation_algorithm name_label GPU_types allocation_algorithm ---------- --------- -------------------- Group NVIDIA GK104GL Corporation [GRID K2] GPU {10de / 11bf} breadth_first Group NVIDIA GK107GL Corporation [GRID K1] GPU {10de / 0ff2} breadth_first 

now we can list some information about types vGPU. VGPU types are pre-sets that can be used to create different types of vGPUs

 PS C :. > Get-XenVGPUType | ft VENDOR_NAME, model_name, framebuffer_size, max_heads, `>> max_resolution_x, max_resolution_y >> VENDOR_NAME model_name framebuffer_size max_heads max_resolution_x max_resolution_y ----------- ---------- ------ ---------- --------- ---------------- --------------- - NVIDIA Corporation GRID K100 268435456 February 1920 10 NVIDIA Corporation GRID K140Q 1006632960 February 2560 10 NVIDIA Corporation GRID K240Q 1006632960 February 2560 10 NVIDIA Corporation GRID K260Q 2,013,265,920 April 2560 10 NVIDIA Corporation GRID K0 268435456 February 1920 10 passthrough 0 0 0 0 

the vGPU type "passthrough" is supported for all PCI display devices, and can be used to create pass-through vGPUs as supported since XenServer 6.0.

We can see where PCI display devices of a type of vGPU is supported as follows:

 PS C: > Get-XenVGPUType | Where {$ _ eq model_name "GRID K100."} `>> | Get-XenVGPUTypeProperty -XenProperty SupportedOnPGPUs `>> | Get-XenPGPU | Get-XenPCI -Ref PCI {$ _.} | select device_name, pci_id >> device_name pci_id ----------- ------ GK107GL [GRID K1] 0000: 0a: 00.0 GK107GL [GRID K1] 0000: 07: 00.0 GK107GL [GRID K1] 0000: 08 : 00.0 GK107GL [GRID K1] 0000: 09: 00.0 

type vGPU will be shown as supported or enabled in a group of GPU if it is supported or enabled respectively in pGPUs least one of the group. We can query the GPU groups to find out what types vGPU are supported or enabled. For example:

 PS C: > Get-XenGPUGroup | Where {$ _ name_label -match "GRID K2".} `>> | Get-XenGPUGroupProperty -XenProperty EnabledVGPUTypes `>> | Get-XenVGPUType | select model_name >> model_name ---------- K0 passthrough GRID GRID GRID K260Q K240Q 

One may want to prohibit certain types of vGPU a pGPU. For example, the following commands disable and enable the type of vGPU Grid K240Q:

 PS C: > $ vgpuType = Get-XenVgpuType | or {. Model_name $ _ eq "GRID K240Q"} PS C: > $ vgpuType | Get-XenVGPUTypeProperty -XenProperty EnabledOnPGPUs `>> | Get-XenPGPU | >> select uuid uuid ---- a913a0d-0be9-aea3-862f-3fbfe1823a3f 8a0d1316-0f09-1ee9-f95b-c778c759ee40 PS C: > Remove-XenPGPUProperty -uuid a913a0d-0be9-aea3-862f-3fbfe1823a3f `>> - EnabledVGPUTypes $ vgputype.opaque_ref >> PS C: > $ vgpuType | Get-XenVGPUTypeProperty -XenProperty EnabledOnPGPUs | get-xenpgpu | select uuid uuid ---- 8a0d1316-0f09-1ee9-f95b-c778c759ee40 PS C: > Add-XenPGPU -uuid a913a0d-0be9-aea3-862f-3fbfe1823a3f -EnabledVGPUTypes $ vgputype.opaque_ref PS C: > $ vgpuType | Get-XenVGPUTypeProperty -XenProperty EnabledOnPGPUs | get-xenpgpu | select uuid uuid ---- a913a0d-0be9-aea3-862f-3fbfe1823a3f 8a0d1316-0f09-1ee9-f95b-c778c759ee40 

One may want to know how much of a certain type vGPUs can be started on the pGPUs in a group, in addition to vGPUs already running:

 PS C: > $ gpuGroups = Get-XenGPUGroup PS C:  > Get-XenVGPUtype | % {Get-XenGPUGroupProperty $ gpuGroups [0] `>> -XenProperty RemainingCapacity -VgpuType $ _} >> 0 0 8 4 16 February 

Now suppose we want to assign a vGPU Grid type K260Q to a VM that has not vGPU. This can be done as follows:

 PS C: > $ vm = Get-XenVm -Name "w7-test" PS C: > $ vgpuTypes = Get-XenVGPUtype PS C : > Get-XenVMProperty -VM $ vm -XenProperty VGPUs PS C: > PS C: > New XenVGPU -VM $ vm $ -GPUGroup gpuGroups [0] -DEVICE 0 -Type $ vgpuTypes [3] -PassThru uuid : f1122947-3b11-3fd3-0630-779701b37265 VM: XenAPI.XenRef`1 [XenAPI.VM] GPU_group: XenAPI.XenRef`1 [XenAPI.GPU_group] device: 0 currently_attached: False other_config: {} type: XenAPI.XenRef`1 [XenAPI.VGPU_type] resident_on: XenAPI.XenRef`1 [XenAPI.PGPU] opaque_ref: OpaqueRef: 15b2d1a9-8944-2f28-53df-6b8274d4d6fb Changed: True 

At this point, we can start the virtual machine, install -Guest in the NVIDIA drivers, and enable RDP. Then, one may want to disable the VNC console because it has significant performance overhead. For this we need to stop the virtual machine, set the vgpu_vnc_enabled flag to false and then start the virtual machine

 PS C :. > Invoke-XenVM -VM $ vm -XenAction Shutdown -async -PassThru `>> | Expect XenTask -ShowProgress >> PS C: > $ p = Get-XenVMProperty -VM $ vm -XenProperty Platform PS C: > $ p ["vgpu_vnc_enabled"] = "false" PS C: > Set-XenVM $ -VM vm -platform $ p PS C: > Invoke-XenVM -VM $ vm -XenAction Start -async -PassThru `>> | Expect XenTask -ShowProgress >> 

Before concluding, we must remember to disconnect from the server:

 PS C: > Get-XenSession | Log XenServer 

We have an active community of users PowerShell more about XenServer SDK forum, where engineers of community development and answer questions and share their expertise, so if for questions please do head there.

Previous
Next Post »
0 Komentar