Ubuntu 伺服器:如何在 Ubuntu 虛擬機器上使用獨立裝置指派 (DDA) 設定 GPU

Summary: 本文示範如何在執行 Hyper-V 的 Ubuntu 伺服器版本 1804 虛擬機器 (VM) 上,使用獨立裝置指派 (DDA) 設定 GPU。

This article applies to This article does not apply to This article is not tied to any specific product. Not all product versions are identified in this article.

Instructions

目標

DDA 可用來將整個 PCIe 裝置 (在此案例中為 GPU) 傳遞至虛擬機器。這允許對設備進行高性能訪問並能夠利用其本機驅動程式。

 

此範例中的環境

伺服器:執行 Windows Server 2019
GPU 的 PowerEdge R740xd:NVIDIA Tesla P100
VM:4 個 vCPU、32 GB RAM,執行 Ubuntu ®18.04 LTS

 

注意:Dell Technologies 建議將更新 BIOS、韌體、驅動程式和作業系統 (OS) 加入至排程更新週期。這些更新旨在改善系統的可靠性、穩定性和安全性。

 

步驟

  1. 在主機上安裝 Windows Server 2019 並更新作業系統。安裝最新的裝置驅動程式,例如晶片組和 GPU 驅動程式。

  2. 安裝 Hyper-V 角色。

  3. 創建第 2 代 VM。在虛擬機器的設定中停用安全開機,然後在其上安裝 Ubuntu ®18.04 LTS。

  4. 套用 Ubuntu 更新。若要這樣做,請執行下列命令:

    $ sudo apt-get update
    $ sudo apt-get upgrade
  5. 關閉虛擬機器。

  6. 在主機上開啟裝置管理員,展開 顯示卡,然後選取要呈現給虛擬機器的 GPU。
    選取 NVIDIA Tesla P100 GPU 的裝置管理員
    圖 1:選取 GPU 的裝置管理員

  7. 以滑鼠右鍵按一下要在虛擬機器中使用的 GPU,然後選取內容。在詳細資訊選項卡中,從位置路徑下拉清單中選擇屬性。將 PCIROOT 開頭的值複製到記事本。
    顯示「位置路徑」屬性的裝置管理員裝置屬性
    圖 2:裝置管理員裝置屬性 - 位置路徑

  8. 在裝置管理員中以滑鼠右鍵按一下 GPU 並將其停用。
    在裝置管理員中停用 GPU
    圖 3:在裝置管理員中停用 GPU

  9. 使用 PowerShell 設定 VM 以執行 DDA。以系統管理員身分開啟 PowerShell,並執行下列命令:

    # Configure the "Automatic Stop Action" of a VM to TurnOff.
    
    Set-VM -Name VMName -AutomaticStopAction TurnOff
    
    # Enable Write-Combining on the CPU.
    
    Set-VM -VMName VMName -GuestControlledCacheTypes $true
    
    # Configure the 32-bit MMIO space.
    
    Set-VM -VMName VMName -LowMemoryMappedIoSpace 128Mb
    
    # Configure greater than 32-bit MMIO space.
    
    Set-VM -VMName VMame -HighMemoryMappedIoSpace 18000Mb
    
    # Dismount the device.
    
    Dismount-VMHostAssignableDevice -force -LocationPath "step 7 location path goes here"
    
    # Assign the device to the VM.
    
    Add-VMAssignableDevice -VMName VMName -LocationPath "step 7 location path goes here"
  10. 啟動虛擬機器。

  11. 在虛擬機器內執行下列命令,以確認已識別 GPU:

    $ lspci
    $ sudo lshw -C Display

    「lspci」和「lshw」命令的輸出
    圖 4:的輸出 lspci lshw 命令

  12. 如果輸出 sudo lshw -C Display 步驟 11 中的命令表示已安裝 Nouveau 驅動程式(請參閱上面圖 4 中的 配置 ),必須禁用它。Nouveau 是由獨立軟體工程師編寫的適用於 NVIDIA 顯卡的免費開源驅動程式。此驅動程式為預設安裝,必須停用才能安裝 NVIDIA 驅動程式。執行下列命令以停用新驅動程式。

    # Create a file at /etc/modprobe.d/blacklist-nouveau.conf.
    
    $ sudo nano /etc/modprobe.d/blacklist-nouveau.conf
    
    # Add the following to the newly created file, then save the file.
    
    blacklist nouveau
    options nouveau modeset=0
    
    # Regenerate the kernel initramfs, then reboot.
    
    $ sudo update-initramfs -u
    $ reboot

    停用新驅動程式後「lspci」和「lshw」命令的輸出
    圖 5:的輸出 lspci lshw 關閉新驅動程式後的命令

  13. 下載 NVIDIA 驅動程式此超連結會帶您前往 Dell Technologies 以外的網站。,然後將其安裝在 Ubuntu 虛擬機器上。

    # Run these commands after the file has been copied to the VM.
    
    $ sudo dpkg -i nvidia-driver-local-repo-ubuntu1804-440.33.01_1.0-1_amd64.deb
    $ sudo apt-key add /var/nvidia-driver-local-repo-440.33.01/7fa2af80.pub
    $ sudo apt-get update
    $ sudo apt-get install cuda-drivers {Install all the dependencies
    $ sudo reboot
  14. 若要確認驅動程式已正確安裝,請執行下列命令:

    $ lspci
    $ sudo lshw -C Display
    $ nvidia-smi

    安裝 NVIDIA 驅動程式後,出現 lspci、lshw 和 nvidia-smi 命令的輸出
    圖 6:的輸出 lspci, lshwnvidia-smi 安裝 NVIDIA 驅動程式後的命令

Additional Information

如何更換 PowerEdge R760 的 GPU

持續時間:00:03:10 (小時:分鐘:秒)
當可用時,您可以使用此影像播放器上的 CC 圖示來選擇隱藏式輔助字幕 (字幕) 語言設定。

Affected Products

Microsoft Windows Server 2019, Microsoft Windows Server 2022, PowerEdge R540, PowerEdge R550, PowerEdge R640, PowerEdge R6415, PowerEdge R650, PowerEdge R650xs, PowerEdge R6515, PowerEdge R6525, PowerEdge R740, PowerEdge R740XD, PowerEdge R740XD2 , PowerEdge R7415, PowerEdge R7425, PowerEdge R750, PowerEdge R750XA, PowerEdge R750xs, PowerEdge R7515, PowerEdge R7525, PowerEdge R840, PowerEdge R940, PowerEdge T640, PowerEdge XE2420, PowerEdge XE7100, PowerEdge XE7420, PowerEdge XE7440, PowerEdge XE8545, Ubuntu Server LTS ...
Article Properties
Article Number: 000106925
Article Type: How To
Last Modified: 17 Dec 2024
Version:  10
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.