Overview

ZStack Cloud supports the Graphics Processing Unit (GPU) passthrough feature. A physical GPU (pGPU), along with all its peripherals (including the GPU graphics card, GPU sound card, and other small devices on the GPU), can be passed through to a VM instance as a group. This allows the VM instance to leverage the powerful parallel computing capabilities of the pGPU. This feature applies to 3D rendering, high-definition transcoding and decoding, as well as High-Performance Computing (HPC) scenarios that demand high computational intensity.

Through passthrough, ZStack Cloud can monitor the load status of GPU devices in real time and sound alarm in abnormal conditions, providing you with a complete and convenient solution for GPU operation and maintenance.

The GPU passthrough feature applies to the pGPUs of the following models.
Vendor Model
NVIDIA
  • Nvidia RTX 6000Ada, Nvidia RTX A6000
  • GeForce RTX 5090, Geforce RTX 4090, Nvidia RTX 3090
  • Quadro RTX 8000, Quadro RTX 6000
  • M4000, P2000
  • GTX 1650/1660, GTX 1060ti
  • H100, H800, H200, H20
  • Nvidia L40, Nvidia L20, Nvidia L4
  • Nvidia A100, A30
  • Nvidia A40, Nvidia A16, Nvidia A10, Nvidia T4
  • Tesla V100, Tesla P4/6/40/100, M6/10/60
  • K6000
  • More NVIDA models, see NVIDIA Official Documentation
AMD
  • Radeon v620, Radeon RX5700
  • FirePro S7150, FirePro S7150X2
HYGON DCU Z100/Z100L, DCU K100 AI
Huawei
  • Atlas 300i Pro
  • 910B/910B4
Note: You can only passthrough Huawei GPUs installed on ARM hosts.
Iluvatar CoreX Zhikai 100, Tiangai
Vastai SV100、SG100
Note: We recommend that you do not passthrough a SG100 GPU to a VM instance directly. The recommended practice is to virtualize SG100 and attach vGPUs to VM instances.
Enflame S60
Note: If you attach more than 5 GPU devices of this type to a VM instance, enter the VM operating system and add event_timeout=300 in the configuration file /etc/udev/udev.conf. This extend the udev timeout to ensure all GPU devices are identified properly.
Other MetaX N100, MOORE TREADS, Cambricon, CloudBlazer

Application Scenarios

3D Rendering

Both Pre-Rendering (or Offline Rendering) and Real-Time Rendering (or Online Rendering) for 3D computer graphics are time-consuming. Pre-Rendering, a technology often used in film-making, demands high computational intensity that needs to be provided by a substantial number of servers. Real-Time Rendering, a technology commonly used in 3D video games, relies on GPUs to complete this process.

Nowadays, with the rapid development of the GPU technology, considerable 3D rendering cases are accomplished in GPU server clusters. With the GPU passthrough feature provided by ZStack Cloud, you can perform centralized cluster management efficiently with a low GPU performance loss (less than 5%). Combined with intelligent monitoring software and the billing service of ZStack Cloud, the feature provides you with a comprehensive, convenient, and efficient rendering farm solution.

Figure 1. 3D Rendering


Artificial Intelligence

GPU supports deep learning tasks due to its compute capability. Since the launch of TensorFlow, a tool for creating neural networks, by Google, GPUs have been gaining favour among research institutes and companies, and adopted as infrastructures.

Take the NVIDIA P100 graphic card as an example, when passed through to a VM instance on ZStack Cloud, test results show that its performance is nearly identical to specifications, fully meeting the infrastructure requirements for large-scale model training.

Figure 2. Artificial Intelligence


Cloud Gaming

With the expansion of broadband networks and the widespread usage of mobile devices, a new trend in gaming has emerged where the computational load is shifted to the cloud, while the client merely handles display and control. In this model, cloud servers undertake the task of 3D game rendering. Combined with GPUs, these cloud servers can encode each frame instantly and stream it to any devices connected to the network.

Leveraging the GPU and server CPU capabilities, this cloud gaming model uses ZStack Cloud’s GPU passthrough feature to create a virtual gaming environment with enhanced isolation and smooth computation and rendering, providing you with an improved gaming experience.

Figure 3. Cloud Gaming


Virtual Desktop Infrastructure (VDI)

GPU has always been an integral part of Virtual Desktop Infrastructure (VDI), for it not only enhances visual experience, but also takes on a primary computational role in special applications, making it a good substitute for traditional PC graphics workstation. Also, GPU enables you to perform 3D designs in a safer environment.

Through the GPU passthrough feature provided by ZStack Cloud, coupled with protocols such as RDP (Remote Desktop Protocol) or PCoIP (PC over IP), you can leverage the GPU to ensure the smooth operation of 3D designs or games and gain the VDI experience as great as that in a physical environment.

Figure 4. VDI


Considerations

To use the GPU passthrough feature, note the following considerations:
  • A single VM instance can attach multiple pGPUs simultaneously but does not support attaching both pGPUs and vGPUs at the same time.
  • After the GPU is passed through to a VM instance, functions such as changing host, changing host and primary storage, or HA may not work well.
  • We recommend that you stop the VM instance before detaching GPUs. Otherwise, a blue screen or a suspension may occur.
  • For GPU passthrough to a Windows VM instance, you need to install the operating system using the UEFI boot mode.
  • Enter the global settings and find PCI Hot Plugging. The default is true. If a hardware incompatibility error occurs during hot plugging or a hardware device does not support hot plugging, you can set this parameter to false.
  • To use the GPU passthrough feature and obtain real-time GPU load monitoring data, you need to install GPU drivers and GuestToos on both the host and the VM instance. The recommended versions for GPU drivers are as follows.
    GPU Recommended Version for Host Recommended Version for VM Instance
    NVIDIA NVIDIA-Linux-x86_64-510.47.03-grid.run Latest version recommended by NVIDIA. For more information, see NVIDIA Official Documentation
    AMD rocm-smi 6.1.2 and later versions rocm-smi 6.1.2 and later versions
    Note: If the VM instance uses the OS of RHEL7 series, make sure that the VM kernel is of 4.18.0 or later versions.
    Hygon

    rock-5.2.0-5.16.29-V01.13.run

    After Hygon uses the GPU passthrough feature, it does not have access to load monitoring data via GPU drivers.
    Huawei

    Ascend-hdk-310p-npu-driver_24.1.rc1_linux-aarch64.run

    Ascend-hdk-310p-npu-driver_24.1.rc1_linux-aarch64.run

    Iluvatar CoreX
    • x86: corex-installer-linux64-4.0.1_x86_64_10.2.run
    • ARM: corex-installer-linux64-4.0.1_arm64_10.2.run
    • x86: corex-installer-linux64-4.0.1_x86_64_10.2.run
    • ARM: corex-installer-linux64-4.0.1_arm64_10.2.run

Preparations

To utilize the GPU passthrough feature on ZStack Cloud, the following preparations are necessary:
  • Enter the BIOS settings of your host and enable the Intel VT-d feature or the AMD IOMMU feature. Verify that the host kernel has IOMMU support enabled.
  • For NVIDIA A series users, you have to ensure that your host kernel is upgraded to 4.18 version, and GCC to 8.3.1 version.
  • Make sure that the version of your driver matches that of your GPU device.
    Note: For more information about driver service or installation methods, please contact GPU device supplier. For recommended driver versions, see Considerations.
  • Configure the global settings: Click Settings > Platform Setting > Global Setting. The following global settings are related to the pGPU passthrough feature, you can adjust them as needed:
    • Hide KVM Virtualization Flag: If you use NVIDIA graphics cards for VM instances, you need to set this parameter to true.

      This setting specifies whether to hide the KVM virtualization flag. The default is false. If set to true, <hidden state='on'> is inserted in the <kvm> field of the XML file defined for a newly started VM instance.

    • VM Hyper-V Virtualization: If you use NVIDIA graphics cards for VM instances, you need to set this parameter to true.

      This setting specifies whether to enable Hyper-V emulation for a VM instance. The default is false.

    • PCI Hot Plugging: Configure it as needed.

      This setting specifies whether to enable hot plugging of PCI devices for a VM instance. The default is true. If a hardware incompatibility error occurs during hot plugging or a hardware device does not support hot plugging, you can set this parameter to false.

    • vGPU Default Quota: Configure it as needed.

      This setting is used to set the quota of GPU devices (including pGPUs and vGPUs) that an account/project can use. The default is 20.

Typical Scenarios

About this task

To pass through a GPU device:
  1. Enable IOMMU in the host BIOS.
  2. Set ROM (Optional).
  3. Attach pGPUs to the VM instance.
  4. Install GPU drivers on the VM instance.
  5. Install GuestTools.

Before using the GPU passthrough feature, ensure that requirements in Preparations have been met completely and correctly. Below is detailed operational procedures for setting up GPU passthrough:

Procedure

  1. Enable IOMMU in the host BIOS.
    Make sure that Intel VT-d or AMD IOMMU is enabled in the host BIOS before you enable the IOMMU option on ZStack Cloud.
    • For adding host: Choose Resource Center > Hardware > Computing Facility > Host > Add Host. Then set Scan Host IOMMU Setting to true to enable IOMMU.
      Figure 5. Add Host and Enable IOMMU


    • For added host: Select one added host and set IOMMU State to true on its details page. Reboot the host and the IOMMU setting will take effect.
      Figure 6. Enable IOMMU for Added Host

    Note: After enabling IOMMU in the host, you have to make sure that IOMMU Status on the same page is available. Otherwise, the GPU passthrough feature cannot work as expected. If IOMMU State is enabled, yet IOMMU Status is unavailable, the reasons could be as follows:
    • The IOMMU setting is enabled but the host is not rebooted. Just reboot the host.
    • If a host configuration error occurs, please enter the host BIOS and enable Intel VT-d or AMD IOMMU.
  2. Set ROM (Optional).

    ROM is a configuration file used for passing through pGPUs. The ROM file you upload is updated to the pGPU that the specification specifies.

    ZStack Cloud provides built-in basic ROM files, which can satisfy the majority of passthrough needs. Additionally, you can obtain other ROM files you need on the official site of the GPU supplier and then upload them.

    On the main menu of ZStack Cloud, choose Resource Center > Resource Pool > Compute Configuration > GPU Specification. Select the pGPU that you need and click Actions > Set ROM. A pop-up menu appears and you can upload ROM file herein.

    Figure 7. Set ROM


    Note: When uploading ROM file, note the following cases:
    • The upoaded ROM file must match the target pGPU's specifications and versions. Otherwise, the passed-through pGPU cannot work properly.
    • The latest ROM file that you upload overwrites the previous ROM file.
  3. Attach pGPUs to the VM instance.
    This step enables the pGPU to be directly passed through to the VM instance. On the ZStack Cloud, you can use the following methods to attach pGPUs to the VM instance:
    • Method One: Create a VM Instance and Attach pGPUs to It
      To create a VM instance, you need to choose Resource Center > Resource Pool > Virtual Resource > VM Instance > Create VM Instance. After you complete Basic Configuration, you come to next stage, that is, Resource Configurations. We support two GPU attachment policies including attaching GPU specification and attaching GPU device. Set the following parameters as you need:
      • Attach GPU Specification: Select a GPU specification and the system allocates GPU device(s) to the VM instance according to this specification. You can choose whether to make these GPU device(s) automatically detached when the VM is stopped. If you set Auto Detach to true, these GPU device(s) would be automatically detached when the VM is stopped. When the VM restarts, the system re-allocates GPU device(s) to it according to the GPU specification. If you set Auto Detach to false, the VM would keep these GPU devices attached and continue using them when it restarts.
        Figure 8. Attach GPU Specification


      • Attach GPU Device: Select a GPU device and attach it directly to the VM instance.
        Figure 9. Attach GPU Device


      After completing the configurations, click OK. Then you'll get a VM instance attached to a pGPU.
    • Method Two: Attach pGPUs to an Existing VM Instance

      In the management interface of VM Instance, select the name of one existing VM instance and enter its details page. Choose Configuration info on the top row. Find pGPU Device on this page and click Attach.

      Figure 10. Attach a pGPU Device


      • A single VM instance can attach multiple pGPUs simultaneously but does not support attaching both pGPUs and vGPUs at the same time.
      • If you want to detach a GPU device, select it and click Actions > Detach.
        Note: If you detach a pGPU from a running VM instance, a blue screen or suspension may occur. We recommend stopping the VM instance before performing detach operation.
    • Method Three: Attach pGPUs to Existing VM Instances

      Select one or more stopped VM instances in the management interface of VM Instance, and click Bulk Action > System Configurations > Set GPU Policy. Then you have two options to choose, that is, attach GPU specification or attach GPU device.

      Figure 11. Attach pGPUs in Bulk


  4. Install GPU drivers on the VM instance.
    After attaching a GPU device to the VM instance, you need to install corresponding GPU drivers. Download paths for AMD or NVIDIA drivers are as follows:
    • Linux OS supports AMD GPU drivers (computing, gaming or professional series included). Linux has built-in community driver, providing you with services such as compute acceleration, displaying acceleration, and checking GPU monitoring. Click here to install the official driver.
    • Linux OS supports NVIDA GPU drivers (computing, gaming or professional series included). Linux has built-in community driver, providing you with services such as compute acceleration, displaying acceleration, and checking GPU monitoring. Click here to install the official driver.
    • Windows OS supports AMD GPU drivers (computing, gaming or professional series included). Click here to download the proper driver that matches the type of GPU and the version of OS.
    • Window OS only supports the computing series of NVIDA GPU drivers. Click here to download the proper driver that matches the type of GPU and the version of OS.
    Note: If you use AMD Firepro S7150 X2 that features two physical GPUs (pGPUs), and want the two pGPUs to be passed through to different VMs, please install the drivers of the same versions on your VMs, so that GPU monitoring data can be obtained normally.
    The procedures of installing the GPU driver vary depending on the version of your GPU device. For more information, you can contact GPU suppliers for assistance. This chapter takes installing a NVIDA GPU on the Linux VM instance as an example. You can refer to the operational procedures below:
    1. Obtain the required driver installation packages:

      Obtain the driver and CUDA toolkit compatible with the GPU device.

    2. Disable the Nouveau kernel driver:
      If NVIDIA drivers conflict with the Nouveau kernel driver, you can run the command lsmod | grep nouveau to check whether the Nouveau driver has been installed. If the output data suggests the Nouveau driver has been installed, you can perform the following operations to disable it. If no output is displayed, just skip this procedure.
      # touch  /etc/modprobe.d/nvidia-installer-disable-nouveau.conf  # Create a file and save the two lines below into it
      blacklist nouveau
      options nouveau modeset=0
    3. Install the gcc, kernel-devel, and kernel-headers files:
      Run the following commands to install the gcc, kernel-devel, and kernel-headers files and ensure that these kernel source files are of the same version. We recommend using the same version of ISO to configure local installations.
      # yum install gcc kernel-devel-$(uname -r)  kernel-headers-$(uname -r)     # Reconstruct initramfs image
      # cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
      # dracut /boot/initramfs-$(uname -r).img $(uname -r) --force       # Only reboot the VM in the text mode
      # systemctl set-default multi-user.target
      # init 3
      # reboot
      # lsmod | grep nouveau    # After the VM instance is rebooted, check whether the nouveau driver is used or not
    4. Install an NVIDIA GPU driver:
      Upload the downloaded package to the VM instance and run the following commands to install the driver.
      # chmod +x NVIDIA-Linux-x86_64-346.47.run    # Configure executable permissions
      # ./NVIDIA-Linux-x86_64-346.47.run      # Execute the driver script 
      After you run the commands, the driver package will begin to unpack and you can follow the installation instructions. During the installation, some warnings may appear. Confirm these warnings in sequence as they do not have any real impact. If some errors occur, please refer to the table below to check the environment.
      Error Message Solution

      ERROR: Unable to find the kernel source tree for the currently running kernel. Please make sure you have installed the kernel source files for your kernel and that they are properly configured; on Red Hat Linux systems, for example, be sure you have the 'kernel-source' or 'kernel-devel' RPM installed. If you know the correct kernel source files are installed, you may specify the kernel source path with the '--kernel-source-path' command line option.

      You need to have all of the kernel source files (including kernel, kernel-headers, and kernel-devel) installed and ensure that they are of the same version

      ERROR: The Nouveau kernel driver is currently in use by your system. This driver is incompatible with the NVIDIA driver, and must be disabled before proceeding. Please consult the ow to correctly disable the Nouveau kernel driver.

      You have to disable the Nouveau kernel driver

      ERROR: Failed to find dkms on the system!

      ERROR: Failed to install the kernel module through DKMS. No kernel module was installed; please try installing again without DKMS, or check the DKMS logs for more information.

      You need to install DKMS, which helps maintain out-of-tree drivers by automatically regenerating new modules when the kernel version changes

      ERROR: Unable to load the kernel module 'nvidia.ko'. This happens most frequently when this kernel module was built against the wrong or improperly configured kernel sources, with a version of gcc that differs from the one used to build the target kernel, or if a driver such as rivafb, nvidiafb, or nouveau is present and prevents the NVIDIA kernel module from obtaining ownership of the NVIDIA graphics device(s), or no NVIDIA GPU installed in this system is supported by this NVIDIA Linux graphics driver release.

      Just run the commands ./NVIDIA-Linux-x86_64-384.98.run --kernel-source-path=/usr/src/kernels/3.10.0-XXX.x86_64/ -k $(uname -r)
    5. Check whether the installation is successful:
      Respectively run the following two commands to check whether the installation is successful. If GPU information such as model is displayed in the command output, the driver has been installed successfully.
      # lspci |grep NVIDIA
      # nvidia-smi
    6. Install the CUDA Toolkit:
      Download CUDA Toolkit installation package and upload this package to the VM system. Run the following commands to execute the driver script:
      # chmod +x cuda_8.0.61_375.26_linux.run      # Configure executable permissions
      # ./cuda_8.0.61_375.26_linux.run     # Execute the driver script 
      During the installation, please set the following parameters:
      Figure 12. Install the CUDA Toolkit


    7. Configure the environment variables:
      Run the vim /root/.bashrc command and save the content below to the same file:
      #gpu driver
      export CUDA_HOME=/usr/local/cuda-8.0
      export PATH=/usr/local/cuda-8.0/bin:$PATH
      export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH
      export LD_LIBRARY_PATH="/usr/local/cuda-8.0/lib:${LD_LIBRARY_PATH}"
      Environment variables will take effect once added. To verify the effect, you can run the following commands:
      # source ~/.bashrc
      # cd /usr/local/cuda-8.0/samples/1_Utilities/deviceQuery
      # make
      # ./deviceQuery
  5. Install GuestTools.
    To capture real-time data on GPU load monitor, GuestTools are required for the VM instance. The procedures of installing GuestTools vary depending on the OS of your VM instance.
    • For Linux VM Instance
      1. Enter the VM instance details page and find GuestTools on the top row.
      2. Attach ISO.
      3. Launch VM console and run the following commands:
        # Create a mount point.
        mkdir /mnt/cdrom
        # Mount the CD-ROM image.
        mount /dev/cdrom /mnt/cdrom
        # Install GuestTools.
        cd /mnt/cdrom/
        bash ./zs-tools-install.sh
        # Unmount the CD-ROM image(Optional)
        cd ~
        umount /mnt/cdrom
        Note:
        • The commands above can be directly copied to VM console.
        • Before you install GuestTools, ensure that you have installed Linux command-line tools, for example, tar, wget, curl.
        • If you install GuestTools for OpenEuler VM, you need to disable selinux. Otherwise, the QGA feature may be affected.
        Figure 13. Install GuestTools | Linux VM Instance




    • For Windows VM Instance
      1. Enter the VM instance detail page and find GuestTools on the top row.
      2. Install ISO.
      3. Launch VM console and follow the steps to install GuestTools.
        Figure 14. Install GuestTools | Windows VM Instance


GPU Passthrough Tutorial | 5.4.12 | ZStack Cloud · ZCF | ZStack Resource Center