NVIDIA
No commands in vSphere 6 to assign GPU profiles to VMs
Hi All, We are using Xendesktop 7.6 FP3 with vSphere 6 and GRID. We are deploying desktops in two different ways. Using, MCS, there is not a full integration with vSphere and GRID as there is with XenServer. To deploy a GPU-enabled desktop with MCS, you need to do the following: -Prepare the gold image with GPU enabled and GRID drivers installed. -Disable the GPU on the gold image. -Create the machine catalog using MCS. -Manually enable the GPU on each virtual desktop created. We want a way to script the last step to add the GPU profile to the newly spawned virtual desktops. From what our team has found, there are not any available commands, in any language, to assign GPU profiles to VMs on vSphere 6. Does anyone know of any commands to do this? We are also deploying full clones via custom scripts but we run into the same problem with a lack of commands to assign GPU profiles to the virtual desktops. Thanks in advance for any help! Richard
Hi All,

We are using Xendesktop 7.6 FP3 with vSphere 6 and GRID. We are deploying desktops in two different ways. Using, MCS, there is not a full integration with vSphere and GRID as there is with XenServer. To deploy a GPU-enabled desktop with MCS, you need to do the following:

-Prepare the gold image with GPU enabled and GRID drivers installed.
-Disable the GPU on the gold image.
-Create the machine catalog using MCS.
-Manually enable the GPU on each virtual desktop created.

We want a way to script the last step to add the GPU profile to the newly spawned virtual desktops. From what our team has found, there are not any available commands, in any language, to assign GPU profiles to VMs on vSphere 6. Does anyone know of any commands to do this?

We are also deploying full clones via custom scripts but we run into the same problem with a lack of commands to assign GPU profiles to the virtual desktops.

Thanks in advance for any help!

Richard

#1
Posted 10/22/2015 04:44 PM   
This article should have you covered. http://www.virtu-al.net/2015/10/26/adding-a-vgpu-for-a-vsphere-6-0-vm-via-powercli/

Jason Southern, Regional Lead for ProVis Sales - EMEA: NVIDIA Ltd.

#2
Posted 10/28/2015 09:16 AM   
Thanks Jason! I was just logging on to update the post with the same article that you did. My co-worker, Matt Wahl, modified the script to accommodate having two GRID cards in the host. The modified script is below. I understand that the original script is written for one GRID card. The script does not yet work for passthrough and we are looking into that. We are going to try the Onyx fling to try to determine the commands used to assign passthrough. https://labs.vmware.com/flings/onyx-for-the-web-client. [CmdletBinding()] Param ( [parameter(Mandatory=$true)] [string]$HostIP, [Parameter(Mandatory=$True)] [string]$GPUProf, [Parameter(Mandatory=$True)] [string]$VMname ) Function Get-GPUProfile { Param ($vmhost) $VMhost = Get-VMhost $VMhost $vmhost.ExtensionData.Config.SharedPassthruGpuTypes } Function Get-vGPUDevice { Param ($vm) $VM = Get-VM -name $VMname $vGPUDevice = $VM.ExtensionData.Config.hardware.Device | Where {$_.backing.vgpu} $vGPUDevice | Select Key, ControllerKey, Unitnumber, @{Name="Device";Expression={$_.DeviceInfo.Label}}, @{Name="Summary";Expression={$_.DeviceInfo.Summary}} } Function Remove-vGPU { Param ( [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true,Position=0)] $VM, [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true,Position=1)] $vGPUDevice ) $ControllerKey = $vGPUDevice.controllerKey $key = $vGPUDevice.Key $UnitNumber = $vGPUDevice.UnitNumber $device = $vGPUDevice.device $Summary = $vGPUDevice.Summary $VM = Get-VM $VM $spec = New-Object VMware.Vim.VirtualMachineConfigSpec $spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[] (1) $spec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec $spec.deviceChange[0].operation = 'remove' $spec.deviceChange[0].device = New-Object VMware.Vim.VirtualPCIPassthrough $spec.deviceChange[0].device.controllerKey = $controllerkey $spec.deviceChange[0].device.unitNumber = $unitnumber $spec.deviceChange[0].device.deviceInfo = New-Object VMware.Vim.Description $spec.deviceChange[0].device.deviceInfo.summary = $summary $spec.deviceChange[0].device.deviceInfo.label = $device $spec.deviceChange[0].device.key = $key $_this = $VM | Get-View $nulloutput = $_this.ReconfigVM_Task($spec) } Function New-vGPU { Param ($VM, $vGPUProfile) $VM = Get-VM $VM $spec = New-Object VMware.Vim.VirtualMachineConfigSpec $spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[] (1) $spec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec $spec.deviceChange[0].operation = 'add' $spec.deviceChange[0].device = New-Object VMware.Vim.VirtualPCIPassthrough $spec.deviceChange[0].device.deviceInfo = New-Object VMware.Vim.Description $spec.deviceChange[0].device.deviceInfo.summary = '' $spec.deviceChange[0].device.deviceInfo.label = 'New PCI device' $spec.deviceChange[0].device.backing = New-Object VMware.Vim.VirtualPCIPassthroughVmiopBackingInfo $spec.deviceChange[0].device.backing.vgpu = "$vGPUProfile" $vmobj = $VM | Get-View $reconfig = $vmobj.ReconfigVM_Task($spec) if ($reconfig) { $ChangedVM = Get-VM $VM $vGPUDevice = $ChangedVM.ExtensionData.Config.hardware.Device | Where { $_.backing.vgpu} $vGPUDevice | Select Key, ControllerKey, Unitnumber, @{Name="Device";Expression={$_.DeviceInfo.Label}}, @{Name="Summary";Expression={$_.DeviceInfo.Summary}} } } $VMHost = Get-VMHost $HostIP $vGPUProfile = Get-GPUProfile -vmhost $VMHost Write-Host "The following vGPU Profiles are available to choose for this host" $vGPUProfile # Choose a profile to use from the list $ChosenvGPUProfile = $vGPUProfile | Where {$_ -like "*$GPUProf*" } write-host "CHOSEN GPU PROFILE :: $ChosenvGPUProfile" # Get a VM to add it to $VM = Get-VM $VMname Write-Host "Adding the vGPU to $vm" New-vGPU -VM $vm -vGPUProfile $ChosenvGPUProfile # At a later date Read-Host "The device has been added, press enter to remove again" Write-Host "Removing the GPU Devices in $VM" Remove-vGPU -VM $vm -vGPUDevice (Get-vGPUDevice -vm $VM)
Thanks Jason! I was just logging on to update the post with the same article that you did.

My co-worker, Matt Wahl, modified the script to accommodate having two GRID cards in the host. The modified script is below. I understand that the original script is written for one GRID card.

The script does not yet work for passthrough and we are looking into that. We are going to try the Onyx fling to try to determine the commands used to assign passthrough. https://labs.vmware.com/flings/onyx-for-the-web-client.


[CmdletBinding()]
Param (
[parameter(Mandatory=$true)]
[string]$HostIP,
[Parameter(Mandatory=$True)]
[string]$GPUProf,
[Parameter(Mandatory=$True)]
[string]$VMname
)


Function Get-GPUProfile {
Param ($vmhost)
$VMhost = Get-VMhost $VMhost
$vmhost.ExtensionData.Config.SharedPassthruGpuTypes
}

Function Get-vGPUDevice {
Param ($vm)
$VM = Get-VM -name $VMname
$vGPUDevice = $VM.ExtensionData.Config.hardware.Device | Where {$_.backing.vgpu}
$vGPUDevice | Select Key, ControllerKey, Unitnumber, @{Name="Device";Expression={$_.DeviceInfo.Label}}, @{Name="Summary";Expression={$_.DeviceInfo.Summary}}
}

Function Remove-vGPU {
Param (
[Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true,Position=0)] $VM,
[Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true,Position=1)] $vGPUDevice
)

$ControllerKey = $vGPUDevice.controllerKey
$key = $vGPUDevice.Key
$UnitNumber = $vGPUDevice.UnitNumber
$device = $vGPUDevice.device
$Summary = $vGPUDevice.Summary

$VM = Get-VM $VM

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[] (1)
$spec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec
$spec.deviceChange[0].operation = 'remove'
$spec.deviceChange[0].device = New-Object VMware.Vim.VirtualPCIPassthrough
$spec.deviceChange[0].device.controllerKey = $controllerkey
$spec.deviceChange[0].device.unitNumber = $unitnumber
$spec.deviceChange[0].device.deviceInfo = New-Object VMware.Vim.Description
$spec.deviceChange[0].device.deviceInfo.summary = $summary
$spec.deviceChange[0].device.deviceInfo.label = $device
$spec.deviceChange[0].device.key = $key
$_this = $VM | Get-View
$nulloutput = $_this.ReconfigVM_Task($spec)
}

Function New-vGPU {
Param ($VM, $vGPUProfile)
$VM = Get-VM $VM
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[] (1)
$spec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec
$spec.deviceChange[0].operation = 'add'
$spec.deviceChange[0].device = New-Object VMware.Vim.VirtualPCIPassthrough
$spec.deviceChange[0].device.deviceInfo = New-Object VMware.Vim.Description
$spec.deviceChange[0].device.deviceInfo.summary = ''
$spec.deviceChange[0].device.deviceInfo.label = 'New PCI device'
$spec.deviceChange[0].device.backing = New-Object VMware.Vim.VirtualPCIPassthroughVmiopBackingInfo
$spec.deviceChange[0].device.backing.vgpu = "$vGPUProfile"
$vmobj = $VM | Get-View
$reconfig = $vmobj.ReconfigVM_Task($spec)
if ($reconfig) {
$ChangedVM = Get-VM $VM
$vGPUDevice = $ChangedVM.ExtensionData.Config.hardware.Device | Where { $_.backing.vgpu}
$vGPUDevice | Select Key, ControllerKey, Unitnumber, @{Name="Device";Expression={$_.DeviceInfo.Label}}, @{Name="Summary";Expression={$_.DeviceInfo.Summary}}

}
}


$VMHost = Get-VMHost $HostIP
$vGPUProfile = Get-GPUProfile -vmhost $VMHost

Write-Host "The following vGPU Profiles are available to choose for this host"
$vGPUProfile

# Choose a profile to use from the list
$ChosenvGPUProfile = $vGPUProfile | Where {$_ -like "*$GPUProf*" }
write-host "CHOSEN GPU PROFILE :: $ChosenvGPUProfile"

# Get a VM to add it to
$VM = Get-VM $VMname

Write-Host "Adding the vGPU to $vm"
New-vGPU -VM $vm -vGPUProfile $ChosenvGPUProfile

# At a later date
Read-Host "The device has been added, press enter to remove again"
Write-Host "Removing the GPU Devices in $VM"
Remove-vGPU -VM $vm -vGPUDevice (Get-vGPUDevice -vm $VM)

#3
Posted 12/15/2015 06:32 PM   
Scroll To Top

Add Reply