在適用于 Azure Stack Edge Pro GPU 裝置的 VM 上安裝 GPU 擴充功能

適用于:適用于 Pro - GPU SKUAzure Stack Edge Pro - Pro2 SKU 的 GPU 是適用于 Pro 2 SKU的 Azure Stack Edge Pro 2是適用于 Pro R SKUAzure Stack Edge Pro R

本文說明如何安裝 GPU 驅動程式擴充功能,以在 Azure Stack Edge 裝置上執行的 GPU VM 上安裝適當的 Nvidia 驅動程式。 本文涵蓋在 Windows 和 Linux VM 上使用 Azure Resource Manager 範本安裝 GPU 擴充功能的安裝步驟。

注意

先決條件

在裝置上執行的 GPU VM 上安裝 GPU 擴充功能之前,請確定:

  1. 您可以存取您已部署一或多個 GPU VM 的 Azure Stack Edge 裝置。 瞭解如何 在裝置上部署 GPU VM

    • 請確定您裝置上針對計算網路啟用的埠已連線到網際網路並具有存取權。 GPU 驅動程式會透過網際網路存取下載。

      以下是埠 2 連線到網際網路並用來啟用計算網路的範例。 如果您的環境未部署 Kubernetes,您可以略過 Kubernetes 節點 IP 和外部服務 IP 指派。

      Azure Stack Edge 裝置 [計算] 窗格的螢幕擷取畫面。埠 2 的計算設定會反白顯示。

  2. 將 GPU 擴充功能範本和參數檔案下載 到您的用戶端電腦。 將它解壓縮到您將作為工作目錄的目錄。

  3. 確認您將用來存取裝置的用戶端仍透過 Azure PowerShell 連線到 Azure Resource Manager。 Azure Resource Manager的連線會每隔 1.5 小時到期,或您的 Azure Stack Edge 裝置重新開機。 如果發生這種情況,您執行的任何 Cmdlet 都會將錯誤訊息傳回至您不再連線到 Azure 的效果。 您必須再次登入。 如需詳細指示,請參閱連線到 Azure Stack Edge 裝置上的 Azure Resource Manager

編輯參數檔案

視 VM 的作業系統而定,您可以安裝適用于 Windows 或 Linux 的 GPU 擴充功能。

若要為現有的 VM 部署 Nvidia GPU 驅動程式,請編輯 addGPUExtWindowsVM.parameters.json 參數檔案,然後部署範本 addGPUextensiontoVM.json

版本 2205 和更新版本

檔案 addGPUExtWindowsVM.parameters.json 會採用下列參數:

"parameters": {	
	"vmName": {
	"value": "<name of the VM>" 
	},
	"extensionName": {
	"value": "<name for the extension. Example: windowsGpu>" 
	},
	"publisher": {
	"value": "Microsoft.HpcCompute" 
	},
	"type": {
	"value": "NvidiaGpuDriverWindows" 
	},
	"typeHandlerVersion": {
	"value": "1.5" 
	},
	"settings": {
	"value": {
	"DriverURL" : "http://us.download.nvidia.com/tesla/511.65/511.65-data-center-tesla-desktop-winserver-2016-2019-2022-dch-international.exe",
	"DriverCertificateUrl" : "https://go.microsoft.com/fwlink/?linkid=871664",
	"DriverType":"CUDA"
	}
	}
	}

低於 2205 的版本

檔案 addGPUExtWindowsVM.parameters.json 會採用下列參數:

"parameters": {	
	"vmName": {
	"value": "<name of the VM>" 
	},
	"extensionName": {
	"value": "<name for the extension. Example: windowsGpu>" 
	},
	"publisher": {
	"value": "Microsoft.HpcCompute" 
	},
	"type": {
	"value": "NvidiaGpuDriverWindows" 
	},
	"typeHandlerVersion": {
	"value": "1.3" 
	},
	"settings": {
	"value": {
	"DriverURL" : "http://us.download.nvidia.com/tesla/442.50/442.50-tesla-desktop-winserver-2019-2016-international.exe",
	"DriverCertificateUrl" : "https://go.microsoft.com/fwlink/?linkid=871664",
	"DriverType":"CUDA"
	}
	}
	}

部署範本

部署範本 addGPUextensiontoVM.json 以在現有的 VM 上安裝擴充功能。

執行以下命令:

$templateFile = "<Path to addGPUextensiontoVM.json>" 
$templateParameterFile = "<Path to addGPUExtWindowsVM.parameters.json>" 
RGName = "<Name of your resource group>"
New-AzureRmResourceGroupDeployment -ResourceGroupName $RGName -TemplateFile $templateFile -TemplateParameterFile $templateParameterFile -Name "<Name for your deployment>"

注意

擴充功能部署是長時間執行的作業,大約需要 10 分鐘才能完成。

以下是範例輸出:

PS C:\WINDOWS\system32> "C:\12-09-2020\ExtensionTemplates\addGPUextensiontoVM.json"
C:\12-09-2020\ExtensionTemplates\addGPUextensiontoVM.json
PS C:\WINDOWS\system32> $templateFile = "C:\12-09-2020\ExtensionTemplates\addGPUextensiontoVM.json"
PS C:\WINDOWS\system32> $templateParameterFile = "C:\12-09-2020\ExtensionTemplates\addGPUExtWindowsVM.parameters.json"
PS C:\WINDOWS\system32> $RGName = "myasegpuvm1"
PS C:\WINDOWS\system32> New-AzureRmResourceGroupDeployment -ResourceGroupName $RGName -TemplateFile $templateFile -TemplateParameterFile $templateParameterFile -Name "deployment3"

DeploymentName          : deployment3
ResourceGroupName       : myasegpuvm1
ProvisioningState       : Succeeded
Timestamp               : 12/16/2020 12:18:50 AM
Mode                    : Incremental
TemplateLink            :
Parameters              :
                       Name             Type                       Value
                       ===============  =========================  ==========
                       vmName           String                     VM2
                       extensionName    String                     windowsgpuext
                       publisher        String                     Microsoft.HpcCompute
                       type             String                     NvidiaGpuDriverWindows
                       typeHandlerVersion  String                     1.3
                       settings         Object                     {
                         "DriverURL": "http://us.download.nvidia.com/tesla/442.50/442.50-tesla-desktop-winserver-2019-2016-international.exe",
                         "DriverCertificateUrl": "https://go.microsoft.com/fwlink/?linkid=871664",
                         "DriverType": "CUDA"
                       }

Outputs                 :
DeploymentDebugLogLevel :
PS C:\WINDOWS\system32>

追蹤部署

若要檢查指定 VM 的擴充功能的部署狀態,請開啟另一個 PowerShell 會話, (以系統管理員身分執行) ,然後執行下列命令:

Get-AzureRmVMExtension -ResourceGroupName <Name of resource group> -VMName <Name of VM> -Name <Name of the extension>

以下是範例輸出:

PS C:\WINDOWS\system32> Get-AzureRmVMExtension -ResourceGroupName myasegpuvm1 -VMName VM2 -Name windowsgpuext

ResourceGroupName       : myasegpuvm1
VMName                  : VM2
Name                    : windowsgpuext
Location                : dbelocal
Etag                    : null
Publisher               : Microsoft.HpcCompute
ExtensionType           : NvidiaGpuDriverWindows
TypeHandlerVersion      : 1.3
Id                      : /subscriptions/947b3cfd-7a1b-4a90-7cc5-e52caf221332/resourceGroups/myasegpuvm1/providers/Microsoft.Compute/virtualMachines/VM2/extensions/windowsgpuext
PublicSettings          : {
                            "DriverURL": "http://us.download.nvidia.com/tesla/442.50/442.50-tesla-desktop-winserver-2019-2016-international.exe",
                            "DriverCertificateUrl": "https://go.microsoft.com/fwlink/?linkid=871664",
                            "DriverType": "CUDA"
                          }
ProtectedSettings       :
ProvisioningState       : Creating
Statuses                :
SubStatuses             :
AutoUpgradeMinorVersion : True
ForceUpdateTag          :

PS C:\WINDOWS\system32>

擴充功能執行輸出會記錄至下列檔案。 請參閱此檔案 C:\Packages\Plugins\Microsoft.HpcCompute.NvidiaGpuDriverWindows\1.3.0.0\Status 以追蹤安裝的狀態。

成功的安裝會以 messageEnable Extensionstatus 表示。 success

"status":  {
                       "formattedMessage":  {
                                                "message":  "Enable Extension",
                                                "lang":  "en"
                                            },
                       "name":  "NvidiaGpuDriverWindows",
                       "status":  "success",

確認驅動程式安裝

登入 VM 並執行與驅動程式一起安裝的 nvidia-smi 命令列公用程式。

版本 2205 和更新版本

nvidia-smi.exe位於 C:\Windows\System32\nvidia-smi.exe 。 如果您沒有看到檔案,驅動程式安裝可能仍在背景中執行。 等候 10 分鐘,然後再檢查一次。

低於 2205 的版本

nvidia-smi.exe位於 C:\Program Files\NVIDIA Corporation\NVSMI\nvidia-smi.exe 。 如果您沒有看到檔案,驅動程式安裝可能仍在背景中執行。 等候 10 分鐘,然後再檢查一次。

如果已安裝驅動程式,您會看到類似下列範例的輸出:

PS C:\Users\Administrator> cd "C:\Program Files\NVIDIA Corporation\NVSMI"
PS C:\Program Files\NVIDIA Corporation\NVSMI> ls

    Directory: C:\Program Files\NVIDIA Corporation\NVSMI

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        2/26/2020  12:00 PM         849640 MCU.exe
-a----        2/26/2020  12:00 PM         443104 nvdebugdump.exe
-a----        2/25/2020   2:06 AM          81823 nvidia-smi.1.pdf
-a----        2/26/2020  12:01 PM         566880 nvidia-smi.exe
-a----        2/26/2020  12:01 PM         991344 nvml.dll

PS C:\Program Files\NVIDIA Corporation\NVSMI> .\nvidia-smi.exe
Wed Dec 16 00:35:51 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 442.50       Driver Version: 442.50       CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla T4            TCC  | 0000503C:00:00.0 Off |                    0 |
| N/A   35C    P8    11W /  70W |      8MiB / 15205MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
PS C:\Program Files\NVIDIA Corporation\NVSMI>

如需詳細資訊,請參閱 適用于 Windows 的 Nvidia GPU 驅動程式擴充功能

注意

安裝 GPU 驅動程式和 GPU 擴充功能之後,您不再需要使用具有網際網路存取的埠進行計算。

移除 GPU 擴充功能

若要移除 GPU 擴充功能,請使用下列命令:

Remove-AzureRmVMExtension -ResourceGroupName <Resource group name> -VMName <VM name> -Name <Extension name>

以下是範例輸出:

PS C:\azure-stack-edge-deploy-vms> Remove-AzureRmVMExtension -ResourceGroupName rgl -VMName WindowsVM -Name windowsgpuext
Virtual machine extension removal operation
This cmdlet will remove the specified virtual machine extension. Do you want to continue? [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y
Requestld IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------    
          True                OK         OK

後續步驟

了解如何: