Overview

ZStack Cloud supports the GPU (Graphics Processing Unit) virtualization feature, which divides physical GPUs (pGPUs) into multiple virtual GPUs (vGPUs) and forms a vGPU pool. You can quickly create lightweight vGPU VM instances based on vGPU specifications, achieving more flexible and scalable resource deployment, optimizing resource utilization, and saving costs. This feature is suitable for lightweight GPU computing scenarios such as cloud gaming, VDI, VR or AR, AI inference, and teaching machine learning.

The GPU virtualization feature applies to the GPU devices of the following models.
Vendor Model
NVIDIA Nvidia RTX 6000Ada, Nvidia RTX A6000
Quadro RTX 8000, Quadro RTX 6000
H100, H200, H800, H20
Note: Supported only by ZStack Cloud H84R ISO.
Nvidia L40, Nvidia L20, Nvidia L4
Nvidia A40, Nvidia A16, Nvidia A10, Nvidia T4
Tesla V100, Tesla P4/6/40/100, M6/10/60
AMD FirePro S7150, FirePro S7150X2
Vastai SV100, SG100

Application Scenarios

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 virtualization feature to divide the pGPU into multiple vGPUs you need and pass them through to VM instances. It creates a virtual gaming environment with enhanced isolation and smooth computation and rendering, providing you with an improved gaming experience.

Figure 1. 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 virtualization feature provided by ZStack Cloud, you can divide pGPUs into multiple customized vGPU devices and pass them through to VM instances. Coupled with protocols such as RDP or PCoIP, you can leverage GPU capabilities while optimizing resource utilization. It enables smooth operation of 3D designs or games, providing you with the VDI experience as great as that in a physical environment.

Figure 2. VDI


Considerations

When using the vGPU feature, note the following considerations:
  • One VM instance can attach only one vGPU at a time and does not support attaching both pGPUs and vGPUs at the same time.
  • A passed-through pGPU cannot be virtualized into multiple vGPUs.
  • To attach or detach vGPUs, ensure that the VM instance is in the stopped state.
  • To virtualize an AMD pGPU requires the host kernel to be of the 3.10 version.
  • To use the GPU virtualization feature and obtain real-time vGPU load monitoring data, you need to install the GPU drivers 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
    • GPU driver: NVIDIA-Linux-x86_64-510.47.03-grid.run
    • vGPU driver: NVIDIA-Linux-x86_64-510.47.03-vgpu-kvm.run
    For the latest version recommended by NVIDIA: See NVIDIA Official Documents
    AMD rocm-smi 6.1.2 and later versions rocm-smi 6.1.2 and above
    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.
    Huawei

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

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

Preparations

NVIDIA GPU Virtualization

To utilize the NVIDIA GPU virtualization feature, the following preparations are necessary:
  • Ensure that the pGPU model supports virtualization.
  • Ensure that the Intel VT-d/AMD IOMMU feature is enabled in the host BIOS, and that the host kernel has IOMMU support enabled.
  • Ensure that SR-IOV and Memory Mapped I/O above 4GB are enabled in the host BIOS.
  • Ensure that the pGPU driver, vGPU driver, and VM vGPU driver have been obtained. For more information about driver service or installation methods, please contact GPU device supplier. For recommended driver versions, see Considerations.
  • 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.
  • To use NVIDIA vGPU software, see NVIDIA Official Documents. Note that you have to purchase the License, set up a License Server, and import the License in advance.
  • Configure the global settings: Click Settings > Platform Settings > Global Settings. The following global settings are related to the pGPU passthrough feature, you can adjust them as needed:
    • PCI Hot-Plugging: Specifies whether to enable hot plugging of GPU 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: Specifies the number of GPU devices (including pGPUs and vGPUs) that an account or a project can use. The default is 20.

AMD GPU Virtualization

To utilize the AMD GPU virtualization feature, the following preparations are necessary:
  • Ensure that the pGPU model supports virtualization.
  • Ensure that the Intel VT-d/AMD IOMMU feature is enabled in the host BIOS, and that the host kernel has IOMMU support enabled.
  • Ensure that the host GPU driver and VM vGPU driver have been obtained. For more information about driver service or installation methods, please contact GPU device supplier. For recommended driver versions, see Considerations.
  • Ensure that the advanced settings VM Instance Hypervisor is set to false, otherwise the VM instance will fail to properly attach the AMD vGPU driver. The advanced setting can be disabled through the following methods:
    • For a VM instance: Enter the details page of the VM instance and choose Advanced settings on the top row. Set VM Instance Hypervisor to false for this VM instance.
    • For a cluster: Enter the details page of the cluster and choose Advanced settings on the top row. Set VM Instance Hypervisor to false for this cluster.
    • For the platform: Click Settings > Platform Settings > Global Settings > Basic Settings. Find VM Instance Hypervisor and set it to false for the entire platform.
  • Set global settings as needed: Click Settings > Platform Settings > Global Settings. The following global settings are related to the pGPU passthrough feature, you can adjust them as needed:
    • PCI Hot-Plugging: Specifies whether to enable hot plugging of GPU 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: Specifies the quota of GPU devices (including pGPUs and vGPUs) that an account or a project can use. The default is 20.

Typical Scenarios

About this task

To use the GPU virtualization feature:
  1. Install GPU drivers and vGPU drivers on the host.
  2. Enable IOMMU in the host BIOS.
  3. Check pGPUs or pGPU specifications.
  4. Virtualize pGPUs.
  5. Check vGPUs or vGPU specifications.
  6. Attach vGPUs to the VM instance.
  7. Install vGPU drivers on the VM instance.

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

Procedure

  1. Install GPU drivers and vGPU drivers on the host.
    After attaching a GPU device to the host, you need to install the corresponding driver to use it properly.
    • NVIDIA: Both the GPU driver and the vGPU driver need to be installed. You can refer to the table Recommended GPU Driver and Click Here to download the appropriate official driver.
    • AMD: The GPU driver need to be installed, while the vGPU driver is automatically generated by ZStack Cloud. You can refer to the table Recommended GPU Driver and Click Here to download the appropriate official driver.
    • Huawei: The GPU driver specified in the table Recommended GPU Driver need to be installed. GPU monitoring and virtualizing both depend on this driver. Contact Huawei's official support to obtain it.
    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 tutorial takes the installation of NVIDIA GPU driver on a host as an example. You can refer to the operational procedures below:
    1. Obtain the required GPU driver installation package.
    2. Install the kernel-devel package matching the kernel version, along with gcc, make, and other required packages.
    3. Run the rpm -i ${GPUDRIVERPACKETNAME} command to install the driver on the host.
    4. Reboot the host and run the nvidia-smi command to check the GPU information. If the host successfully detects the GPU device, the GPU driver has been successfully installed on the host.
  2. 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, set Scan Host IOMMU Setting to true to enable IOMMU.
      Figure 3. 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 4. Enable IOMMU for Added host


    Note: After enabling the IOMMU setting on the host, you also need to ensure that IOMMU Status on the same page is available. Otherwise, the GPU virtualization feature cannot work as expected. If IOMMU State is enabled, yet the IOMMU Status is unavailable, the reason 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.
  3. Check pGPUs or pGPU Specifications.
    When the IOMMU state is enabled, and the IOMMU status is available, ZStack Cloud can detect the pGPU and its specifications on the host.
    • Check pGPUs: On the host details page, select one added host and chooseAssociated Resource > PCI Device > Physical GPU to check the pGPU devices detected on this host.
    • Check pGPU specifications:

      On the main menu of ZStack Cloud, choose Resource Center > Resource Pool > Compute Configuration > GPU Specification. On the GPU Specification page, check the scanned pGPU specifications.

  4. Virtualize pGPUs.
    Virtualizing pGPUs means dividing the pGPUs unallocated for passthrough into multiple specified vGPUs. Methods for pGPU virtualization vary slightly depending on GPU manufacturers. Currently, ZStack Cloud supports the virtualization of NVIDIA pGPUs and AMD pGPUs.
    • Virtualize NVIDIA pGPUs: Supports virtualizing NVIDIA pGPUs according to the selected specifications.

      On the host details page, select one added host and choose Associated Resource > PCI Device > Physical GPU. You have to select a virtualizable pGPU and click Action > Virtualization. The same is true of virtualizing AMD pGPUs.

      The virtualization specification lists all the specifications this pGPU can be virtualized into. For example: GRID M60-2A(4ins-2048 MiB-1280*1024) implies that a core pGPU is virtualized into 4 vGPUs with a frame rate of 60FPS, graphics memory of 2048MB, and a resolution of 1280*1024.
      Note: If you need to restore the vGPU to a pGPU, click Action > Ungenerate. To restore the NVIDIA vGPU, ensure that all the vGPUs related to this pGPU have been detached from the VM instance.
    • Virtualize AMD pGPUs: Not only supports virtualizing AMD pGPUs according to the selected number, but also supports virtualizing all the AMD pGPUs on the host at the same time.

      Note: If you need to restore the vGPU to a pGPU, click Action > Ungenerate. Before restoring the AMD vGPU, ensure that all AMD vGPUs related to the current AMD graphics card have been detached from the VM instance.
  5. Check vGPUs or vGPU specifications.
    Once the virtualization is completed, vGPUs and vGPU specifications will present themselves. You can check them on the corresponding page.
    • Check vGPUs:

      On the host details page, select one added host and choose Associated Resource > PCI Device > vGPU to check the vGPU devices on the host.

    • Check vGPU specifications:

      On the main menu of ZStack Cloud, choose Resource Center > Resource Pool > Compute Configuration > GPU Specification > vGPU Specification to check the vGPU specifications.

  6. Attach vGPUs to the VM instance.
    On ZStack Cloud, you can use the following methods to attach vGPUs to the VM instance:
    • Method 1: Create a VM instance and attach vGPUs 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 vGPU specification and the system allocates vGPU device(s) to the VM instance according to this specification. You can choose whether to make these vGPU device(s) automatically detached when the VM is stopped. If you set Auto Detach to true, these vGPU device(s) would be automatically detached when the VM is stopped. When the VM restarts, the system re-allocates vGPU device(s) to it according to the GPU specification. If you set Auto Detach to false, the VM would keep these vGPU devices attached and continue using them when it restarts.
        Note: if the VM is stopped unexpectedly when Auto Detach is set to false, it cannot automatically start even though its HA mode is NeverStop.
      • Attach GPU Device: Select a vGPU device and attach it directly to the VM instance.
      After completing the configurations, click OK. Then you'll get a VM instance with vGPUs attached.
    • Method 2: Attach vGPUs to an Existing VM Instance

      On the main menu of ZStack Cloud, choose Resource Pool > VM Instance. On the VM Instance page, click the name of an existing VM instance to enter its details page. Choose Configuration info on the top row. Find vGPU Device on this page and click Attach.

      • One VM instance can attach only one vGPU at a time and 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.
      • To attach or detach vGPUs, ensure that the VM instance is in the Stopped state.
    • Method 3: Attach vGPUs 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.

  7. Install vGPU drivers on the VM instance
    After attaching a GPU device to the VM instance, you need to install corresponding GPU drivers. The procedures of installing the vGPU driver vary depending on the version of your vGPU. 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 related driver installation files:

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

    2. Disable the Nouveau 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 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.

      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      #Set executable permission
      # ./cuda_8.0.61_375.26_linux.run     #Run the driver file

      During the installation, please set the following parameters:

      Figure 5. Install CUDA Toolkit


    7. Configure 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
GPU Virtualization Tutorial | 5.5.30 | ZStack Cloud · ZCF | ZStack Resource Center