共用方式為


適用於 Windows 的 Azure IoT Edge on Linux 的 GPU 加速

適用於:IoT Edge 1.5 勾選標記 IoT Edge 1.5

重要

IoT Edge 1.5 LTS 是支援的版本。 IoT Edge 1.4 LTS 於 2024 年 11 月 12 日終止生命週期。 如果你使用的是較早版本,請參考 Update IoT Edge

GPU 是人工智慧計算的熱門選擇,因為它們提供平行處理功能,而且通常會比 CPU 更快執行以視覺為基礎的推斷。 為了支援人工智慧與機器學習應用,Azure IoT Edge for Linux on Windows(EFLOW)將 GPU 暴露給虛擬機的 Linux 模組。

Azure IoT Edge for Linux on Windows 支援多種 GPU 直通技術,包括:

  • 直接裝置指派 (DDA) - GPU 核心會配置給 Linux 虛擬機器或主機。

  • GPU 半虛擬化 (GPU-PV) - GPU 會在 Linux 虛擬機器與主機之間共用。

您必須在部署期間選取適當的傳遞方法,以符合您裝置 GPU 硬體支援的功能。

重要

這些功能可能包括 NVIDIA Corporation 或其授權者所開發及擁有的元件。 元件的使用是由位於 NVIDIA 網站上的 NVIDIA 使用者授權合約所控管。

藉由使用 GPU 加速功能,您接受並同意 NVIDIA End-User 許可協定的條款。

必要條件

Azure IoT Edge for Linux for Windows 的 GPU 加速功能目前支援部分 GPU 硬體。 此外,使用此功能可能需要特定版本的 Windows。

支援的 GPU 及必要的 Windows 版本包括:

支援的 GPU GPU 傳遞類型 支援的 Windows 版本
NVIDIA T4、A2 DDA Windows Server 2019
Windows Server 2022
Windows 10/11 (Pro、Enterprise、IoT Enterprise)
NVIDIA GeForce、Quadro、RTX GPU-PV Windows 10/11 (Pro、Enterprise、IoT Enterprise)
英特爾核顯 GPU-PV Windows 10/11 (Pro、Enterprise、IoT Enterprise)

重要

GPU-PV 支援可以限制為特定幾代處理器或 GPU 架構,如 GPU 廠商所決定。 如需詳細資訊,請參閱 Intel 的 iGPU 驅動程式文件NVIDIA 的 CUDA for WSL 文件

Windows Server 2019 使用者必須使用最低建置版本 17763,並安裝所有目前累積更新。

Windows 10使用者必須使用 November 2021 更新版本,版本為 19044.1620 或更高版本。 安裝之後,請在命令提示字元中執行 winver ,以檢查組建版本。

GPU 傳遞不支援嵌套虛擬化,例如在 Windows 虛擬機器中運行 EFLOW。

系統設定和安裝

下列各節包含根據您的 GPU 設定和安裝資訊。

NVIDIA T4/A2 GPU

針對 T4/A2 GPU,Microsoft 建議安裝來自 GPU 廠商的裝置風險降低驅動程式。 雖然是選擇性的,但安裝風險降低驅動程式可以改善部署的安全性。 如需詳細資訊,請參閱使用直接裝置指派來部署圖形卡裝置

警告

啟用硬體裝置傳遞可能會增加安全性風險。 當適用時,Microsoft 會建議使用來自 GPU 廠商的裝置風險降低驅動程式。 如需詳細資訊,請參閱使用離散裝置指派來部署圖表裝置

NVIDIA GeForce/Quadro/RTX GPU

對於NVIDIA GeForce/Quadro/RTX GPU,請下載並安裝啟用NVIDIA CUDA 驅動程式用於 Windows Subsystem for Linux (WSL),以配合現有的 CUDA ML 工作流程使用。 CUDA 最初為 WSL 開發,WSL 驅動程式也用於 Windows 上的 Azure IoT Edge for Linux。

Windows 10 使用者也必須安裝 WSL,因為部分函式庫在 WSL 與 Linux on Windows 的 Azure IoT Edge 之間是共用的。

Intel iGPU

針對 Intel iGPU,請下載並安裝具有 WSL GPU 支援的 Intel 圖形卡驅動程式

Windows 10 使用者也必須安裝 WSL,因為部分函式庫在 WSL 與 Linux on Windows 的 Azure IoT Edge 之間是共用的。

在您的 Azure IoT Edge Linux on Windows 部署中啟用 GPU 加速

系統設定完成後,開始建立你在 Windows 上為 Linux 部署的 Azure IoT Edge。 在此程式中,啟用 GPU 支援 作為 EFLOW 部署的一部分。

例如,這些命令會使用 NVIDIA A2 GPU 或 Intel Iris Xe 圖形卡來建立已啟用 GPU 的虛擬機。

#Deploys EFLOW with NVIDIA A2 assigned to the EFLOW VM
Deploy-Eflow -gpuPassthroughType DirectDeviceAssignment -gpuCount 1 -gpuName "NVIDIA A2"

#Deploys EFLOW with Intel(R) Iris(R) Xe Graphics assigned to the EFLOW VM
Deploy-Eflow -gpuPassthroughType ParaVirtualization -gpuCount 1 -gpuName "Intel(R) Iris(R) Xe Graphics"

要找到你的顯示卡名稱,可以執行這個指令或在 Device Manager 裡找 Display adapters。

(Get-WmiObject win32_VideoController).caption

安裝完成後,透過 Azure IoT Edge for Linux 在 Windows 上部署並執行 GPU 加速的 Linux 模組。

在現有的 Azure IoT Edge Linux on Windows 部署中配置 GPU 加速

在部署時指派 GPU 以取得最直接的體驗。 若要在部署後啟用或停用 GPU,請使用 set-eflowvm 命令。 當您使用 set-eflowvm時,預設參數會用於您未指定的任何自變數。 例如,

# Deploys EFLOW without a GPU assigned to the EFLOW VM
Deploy-Eflow -cpuCount 4 -memoryInMB 16384

# Assigns NVIDIA A2 GPU to the existing deployment (cpu and memory must still be specified, or they're set to the default values)
Set-EflowVM -cpuCount 4 -memoryInMB 16384 -gpuName "NVIDIA A2" -gpuPassthroughType DirectDeviceAssignment -gpuCount 1

# Reduces the cpuCount and memory (GPU must still be specified, or the GPU is removed)
Set-EflowVM -cpuCount 2 -memoryInMB 4096 -gpuName "NVIDIA A2" -gpuPassthroughType DirectDeviceAssignment -gpuCount 1

# Removes NVIDIA A2 GPU from the existing deployment
Set-EflowVM -cpuCount 2 -memoryInMB 4096

下一步

  • 試試 EFLOW 取樣中的 GPU 取樣。 這些範例顯示常見的製造和零售情境,例如瑕疵檢測、工人安全和庫存管理。 這些開放原始碼範例可以是建置您自己的視覺型機器學習應用程式的解決方案範本。

  • DDA 檔和GPU-PV 部落格文章中深入瞭解 GPU 傳遞技術。

數個 GPU 廠商提供使用 EFLOW 充分利用其硬體和軟體的使用者指南: