你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

适用于 Windows 的 NVIDIA GPU 驱动程序扩展

适用于 Windows 的 NVIDIA GPU 驱动程序扩展在 Windows N 系列虚拟机 (VM) 上安装 NVIDIA GPU 驱动程序。 根据 VM 系列,此扩展安装 CUDA 或 GRID 驱动程序。 使用此扩展安装 NVIDIA 驱动程序时,即表示你接受并同意 NVIDIA 最终用户许可协议条款。 在安装过程中,VM 可能会重新启动以完成驱动程序安装。

可查看驱动程序的手动安装说明以及当前支持的版本列表。 有关详细信息,请参阅在运行 Windows 的 N 系列 VM 上安装 NVIDIA GPU 驱动程序

NVIDIA GPU 驱动程序扩展也可以部署在 Linux N 系列虚拟机上。 有关详细信息,请参阅适用于 Linux 的 NVIDIA GPU 驱动程序扩展

注意

安装扩展后,GPU 驱动程序扩展不会自动更新驱动程序。 如果需要移动到较新的驱动程序版本,请手动下载并安装驱动程序,或者移除再添加扩展。

先决条件

确认虚拟机满足使用 NVIDIA GPU 驱动程序扩展的必备条件。

操作系统支持

NVIDIA GPU 驱动程序扩展支持以下 Windows 版本:

分发 版本
Windows 11 核心
Windows 10 核心
Windows Server 2022 核心
Windows Server 2019 核心
Windows Server 2016 核心
Windows Server 2012 R2 核心

需要 Internet 连接

NVIDIA GPU 驱动程序扩展要求目标虚拟机连接到 Internet 并具有访问权限。

查看扩展架构

以下 JSON 代码片段显示此扩展的架构:

{
  "name": "<myExtensionName>",
  "type": "extensions",
  "apiVersion": "2015-06-15",
  "location": "<location>",
  "dependsOn": [
    "[concat('Microsoft.Compute/virtualMachines/', <myVM>)]"
  ],
  "properties": {
    "publisher": "Microsoft.HpcCompute",
    "type": "NvidiaGpuDriverWindows",
    "typeHandlerVersion": "1.4",
    "autoUpgradeMinorVersion": true,
    "settings": {
    }
  }
}

属性

JSON 模式包括以下参数的值。

名称 值/示例 数据类型
apiVersion 2015-06-15 date
publisher Microsoft.HpcCompute string
type NvidiaGpuDriverWindows string
typeHandlerVersion 1.4 int

部署扩展

可以使用 Azure CLI、PowerShell、Azure 资源管理器 (ARM) 模板和 Azure 门户管理 Azure VM 扩展。

注意

下面的一些示例在命令中使用 <placeholder> 参数值。 在运行每个命令之前,请确保将任何占位符值替换为配置的特定值。

Azure 门户

要在 Azure 门户中安装 NVIDIA GPU 驱动程序扩展,请执行以下步骤:

  1. Azure 门户中,转到要在其上安装扩展的虚拟机。

  2. 在“设置”下,选择“扩展 + 应用程序”。

    Screenshot that shows how to select Extensions + Applications for a virtual machine in the Azure portal.

  3. 在“扩展”下,选择“+ 添加”。

    Screenshot that shows how to add an extension for a virtual machine in the Azure portal.

  4. 找到并选择 NVIDIA GPU 驱动程序扩展,然后选择“下一步”。

    Screenshot that shows how to locate and select the NVIDIA GPU Driver Extension for a virtual machine in the Azure portal.

  5. 选择“查看 + 创建”。 确认部署操作,然后选择“创建”。

    请等待几分钟,以便部署扩展。

    Screenshot that shows how to create the NVIDIA GPU Driver Extension on the selected virtual machine in the Azure portal.

  6. 确认扩展已列为虚拟机的已安装扩展。

    Screenshot that shows the NVIDIA GPU Driver Extension in the list of extensions for the virtual machine in the Azure portal.

ARM 模板

部署一个或多个需要部署后配置的虚拟机时,ARM 模板是理想的选择。

虚拟机扩展的 JSON 配置可以嵌套在虚拟机资源内,或放置在 JSON ARM 模板的根级别或顶级别。 JSON 配置的位置会影响资源 nametype 的值。 有关详细信息,请参阅设置子资源的名称和类型

以下示例假定扩展嵌套在虚拟机资源内。 嵌套扩展资源时,JSON 放置在虚拟机的 "resources": [] 对象中。

{
  "name": "<myExtensionName>",
  "type": "extensions",
  "location": "[<resourceGroup().location>]",
  "apiVersion": "2015-06-15",
  "dependsOn": [
    "[concat('Microsoft.Compute/virtualMachines/', <myVM>)]"
  ],
  "properties": {
    "publisher": "Microsoft.HpcCompute",
    "type": "NvidiaGpuDriverWindows",
    "typeHandlerVersion": "1.4",
    "autoUpgradeMinorVersion": true,
    "settings": {
    }
  }
}

PowerShell

使用以下 PowerShell 命令将 NVIDIA GPU 驱动程序扩展部署到虚拟机。

Set-AzVMExtension
    -ResourceGroupName "<myResourceGroup>" `
    -VMName "<myVM>" `
    -Location "<location>" `
    -Publisher "Microsoft.HpcCompute" `
    -ExtensionName "NvidiaGpuDriverWindows" `
    -ExtensionType "NvidiaGpuDriverWindows" `
    -TypeHandlerVersion 1.4 `
    -SettingString '{ `
	}'

Azure CLI

在 Azure CLI 中运行以下命令,将 NVIDIA GPU 驱动程序扩展部署到虚拟机。

az vm extension set \
  --resource-group <myResourceGroup> \
  --vm-name <myVM> \
  --name NvidiaGpuDriverWindows \
  --publisher Microsoft.HpcCompute \
  --version 1.4 \
  --settings '{ \
  }'

排查问题

下面是有关如何排查部署问题的一些建议。

检查扩展状态

在 Azure 门户中通过使用 PowerShell 或 Azure CLI 来检查扩展部署的状态。

若要查看指定 VM 的扩展部署状态,请运行以下命令:

Get-AzVMExtension -ResourceGroupName <myResourceGroup> -VMName <myVM> -Name <myExtensionName>
az vm extension list --resource-group <myResourceGroup> --vm-name <myVM> -o table

查看输出日志

C:\WindowsAzure\Logs\Plugins\Microsoft.HpcCompute.NvidiaGpuDriverWindows\ 下查看 NVIDIA GPU 驱动程序扩展部署的输出日志。

响应错误代码

下表列出了部署和潜在后续操作的常见错误代码。

错误 说明 操作
0 操作成功。 无需采取任何行动。
1 操作成功。 重新启动。
100 操作不受支持或无法完成。 检查日志文件以确定错误原因,例如:
- 不支持 PowerShell 版本。
- 虚拟机大小不是 N 系列虚拟机。
- 数据下载过程中出现故障。
240, 840 操作超时。 请重试操作。
-1 发生异常。 请检查日志文件,以确定异常原因。
-5x 由于重新启动未完成,导致操作中断。 重启 VM。 重新启动后,安装将继续。
应手动调用卸载。

获取支持

下面是一些其他选项,可帮助你解决部署问题:

后续步骤