with its N-series VMs that expose NVIDIA cards to VMs. However, Microsoft and
NVIDIA performed extensive penetration testing, resulting in a safe method to enable
this functionality in Azure.
The host must be running Windows Server 2016. However, the guest OS can be
Windows Server 2016, Windows Server 2012 R2, Windows 10 (1511 and above), and
certain Linux distributions. This is the technology that will be leveraged to enable the
N-series VMs in Azure that have GPU capabilities by directly mapping GPUs to Azure
VMs.
To use DDA, you need first to unload the default driver from the device you wish to
map to a VM, dismount the device from the management OS, and then you can map it
to a VM. The following script, which will dismount NVMe devices on the system,
making them available to VMs, is from this article:
https://blogs.technet.microsoft.com/virtualization/2015/11/19/
discrete-device-assignment-description-and-background/
get all devices which are NVMe controllers
$pnpdevs = Get-PnpDevice -PresentOnly | Where-Object {$.Class -eq
"SCSIAdapter"} | Where-Object {$.Service -eq "stornvme"}
cycle through them disabling and dismounting them
foreach ($pnpdev in $pnpdevs)
{
disable-pnpdevice -InstanceId $pnpdev.InstanceId -Confirm:$false
$locationpath = ($pnpdev | get-pnpdeviceproperty
DEVPKEY_Device_LocationPaths).data[0]
dismount-vmhostassignabledevice -locationpath $locationpath
$locationpath
}
The output of the script will include the devices that were identified and unmounted.
These devices can also now be seen by executing the Get-VMHostAssignableDevice
cmdlet, which includes a property named LocationPath. It is the LocationPath that
you specify when mapping a device to a VM via DDA using the Add-
VMAssignableDevice cmdlet, for example:
PS C:> Get-VMHostAssignableDevice
InstanceID : PCIP\VEN_144D&DEV_A820&SUBSYS_1F951028&REV_03\4&368722DD&0&0010
LocationPath : PCIROOT(40)#PCI(0200)#PCI(0000)
CimSession : CimSession: .
ComputerName : SAVDALHVFX
IsDeleted : False
PS C:> Add-VMAssignableDevice -LocationPath
"PCIROOT(40)#PCI(0200)#PCI(0000)" -VMName TestVM
To remove a device from a VM, use Remove-VMAssignableDevice with the same
parameters as the Add cmdlet. There is no graphical interface to manage DDA—you
must use PowerShell. Remember that since this is direct mapping of a device to a VM,