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

警告

這篇文章參考 CentOS,這是接近生命週期結束 (EOL) 狀態的 Linux 發行版本。 請據以考慮您的使用方式和規劃。 如需詳細資訊,請參閱 CentOS 生命週期結束指引

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

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

注意

  • 在 Azure 入口網站 中,您可以在 VM 建立期間或部署 VM 之後安裝 GPU 擴充功能。 如需步驟和需求,請參閱 部署 GPU 虛擬機
  • 如果您正在執行 Windows 2016 VHD,您必須先在 VM 內啟用 TLS 1.2,才能在 2205 和更新版本上安裝 GPU 擴充功能。 如需詳細步驟,請參閱 針對 Azure Stack Edge Pro GPU 上 GPU VM 的 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

下一步

了解如何: