此内容没有您所选择的语言版本。
Chapter 11. Configuring virtual GPUs for instances
To support GPU-based rendering on your instances, you can define and manage virtual GPU (vGPU) resources according to your available physical GPU devices and your hypervisor type. You can use this configuration to divide the rendering workloads between all your physical GPU devices more effectively, and to have more control over scheduling your vGPU-enabled instances.
To enable vGPU in OpenStack Compute, create flavors that your cloud users can use to create Red Hat Enterprise Linux (RHEL) instances with vGPU devices. Each instance can then support GPU workloads with virtual GPU devices that correspond to the physical GPU devices.
The OpenStack Compute service tracks the number of vGPU devices that are available for each GPU profile you define on each host. The Compute service schedules instances to these hosts based on the flavor, attaches the devices, and monitors usage on an ongoing basis. When an instance is deleted, the Compute service adds the vGPU devices back to the available pool.
11.1. Supported configurations and limitations 复制链接链接已复制到粘贴板!
Supported GPU cards
For a list of supported NVIDIA GPU cards, see Virtual GPU Software Supported Products on the NVIDIA website.
Limitations when using vGPU devices
- You can enable only one vGPU type on each Compute node.
- Each instance can use only one vGPU resource.
- Live migration of vGPU between hosts is not supported.
- Suspend operations on a vGPU-enabled instance is not supported due to a libvirt limitation. Instead, you can snapshot or shelve the instance.
- Resize and cold migration operations on an instance with a vGPU flavor does not automatically re-allocate the vGPU resources to the instance. After you resize or migrate the instance, you must rebuild it manually to re-allocate the vGPU resources.
- By default, vGPU types on Compute hosts are not exposed to API users. To grant access, add the hosts to a host aggregate. For more information, see Section 4.4, “Managing host aggregates”.
- If you use NVIDIA accelerator hardware, you must comply with the NVIDIA licensing requirements. For example, NVIDIA vGPU GRID requires a licensing server. For more information about the NVIDIA licensing requirements, see NVIDIA License Server Release Notes on the NVIDIA website.
11.2. Configuring vGPU on the Compute nodes 复制链接链接已复制到粘贴板!
To enable your cloud users to create instances that use a virtual GPU (vGPU), you must configure the Compute nodes that have the physical GPUs:
- Build a custom GPU-enabled overcloud image.
- Prepare the GPU role, profile, and flavor for designating Compute nodes for vGPU.
- Configure the Compute node for vGPU.
- Deploy the overcloud.
To use an NVIDIA GRID vGPU, you must comply with the NVIDIA GRID licensing requirements and you must have the URL of your self-hosted license server. For more information, see the NVIDIA License Server Release Notes web page.
11.2.1. Building a custom GPU overcloud image 复制链接链接已复制到粘贴板!
Perform the following steps on the director node to install the NVIDIA GRID host driver on an overcloud Compute image and upload the image to the OpenStack Image service (glance).
Procedure
Copy the overcloud image and add the
gpu
suffix to the copied image.cp overcloud-full.qcow2 overcloud-full-gpu.qcow2
$ cp overcloud-full.qcow2 overcloud-full-gpu.qcow2
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Install an ISO image generator tool from YUM.
sudo yum install genisoimage -y
$ sudo yum install genisoimage -y
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Download the NVIDIA GRID host driver RPM package that corresponds to your GPU device from the NVIDIA website. To determine which driver you need, see the NVIDIA Driver Downloads Portal.
NoteYou must be a registered NVIDIA customer to download the drivers from the portal.
Create an ISO image from the driver RPM package and save the image in the
nvidia-host
directory.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a driver installation script that also disables the nouveau driver and generates a new initramfs. The following example script,
install_nvidia.sh
, disables the nouveau driver, generates a new initramfs, and installs the NVIDIA GRID host driver on the overcloud image:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Replace
<host_driver>
with the host driver downloaded in step 3.
-
Replace
Customize the overcloud image by attaching the ISO image that you generated in step 4, and running the driver installation script that you created in step 5:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Relabel the customized image with SELinux:
virt-customize -a overcloud-full-gpu.qcow2 --selinux-relabel
$ virt-customize -a overcloud-full-gpu.qcow2 --selinux-relabel [ 0.0] Examining the guest ... [ 2.2] Setting a random seed [ 2.2] SELinux relabelling [ 27.4] Finishing off
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Prepare the custom image files for upload to the OpenStack Image Service:
mkdir /var/image/x86_64/image guestmount -a overcloud-full-gpu.qcow2 -i --ro image cp image/boot/vmlinuz-3.10.0-862.14.4.el8.x86_64 ./overcloud-full-gpu.vmlinuz cp image/boot/initramfs-3.10.0-862.14.4.el8.x86_64.img ./overcloud-full-gpu.initrd
$ mkdir /var/image/x86_64/image $ guestmount -a overcloud-full-gpu.qcow2 -i --ro image $ cp image/boot/vmlinuz-3.10.0-862.14.4.el8.x86_64 ./overcloud-full-gpu.vmlinuz $ cp image/boot/initramfs-3.10.0-862.14.4.el8.x86_64.img ./overcloud-full-gpu.initrd
Copy to Clipboard Copied! Toggle word wrap Toggle overflow From the undercloud, upload the custom image to the OpenStack Image Service:
(undercloud) $ openstack overcloud image upload --update-existing --os-image-name overcloud-full-gpu.qcow2
(undercloud) $ openstack overcloud image upload --update-existing --os-image-name overcloud-full-gpu.qcow2
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
11.2.2. Designating Compute nodes for vGPU 复制链接链接已复制到粘贴板!
To designate Compute nodes for vGPU workloads, you must create a new role file to configure the vGPU role, and configure a new flavor to use to tag the GPU-enabled Compute nodes.
Procedure
To create the new
ComputeGpu
role file, copy the file/usr/share/openstack-tripleo-heat-templates/roles/Compute.yaml
to/usr/share/openstack-tripleo-heat-templates/roles/ComputeGpu.yaml
and edit or add the following file sections:Expand Table 11.1. ComputeGpu role file edits Section/Parameter Current value New value Role comment
Role: Compute
Role: ComputeGpu
Role name
name: Compute
name: ComputeGpu
description
Basic Compute Node role
GPU Compute Node role
ImageDefault
n/a
overcloud-full-gpu
HostnameFormatDefault
-compute-
-computegpu-
deprecated_nic_config_name
compute.yaml
compute-gpu.yaml
The following example shows the
ComputeGpu
role details:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Generate a new roles data file named
roles_data_gpu.yaml
that includes theController
,Compute
, andComputeGpu
roles:openstack overcloud roles \ generate -o /home/stack/templates/roles_data_gpu.yaml \ ComputeGpu Compute Controller
(undercloud) [stack@director templates]$ openstack overcloud roles \ generate -o /home/stack/templates/roles_data_gpu.yaml \ ComputeGpu Compute Controller
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Register the node for the overcloud. For more information, see Registering nodes for the overcloud in the Director Installation and Usage guide.
- Inspect the node hardware. For more information, see Inspecting the hardware of nodes in the Director Installation and Usage guide.
Create the
compute-vgpu-nvidia
flavor to use to tag nodes that you want to designate for vGPU workloads:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Tag each node that you want to designate for GPU workloads with the
compute-vgpu-nvidia
profile.openstack baremetal node set --property capabilities='profile:compute-vgpu-nvidia,boot_option:local' <node>
(undercloud) [stack@director templates]$ openstack baremetal node set --property capabilities='profile:compute-vgpu-nvidia,boot_option:local' <node>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
<node>
with the ID of the baremetal node.To verify the role is created, enter the following command:
openstack overcloud profiles list
(undercloud) [stack@director templates]$ openstack overcloud profiles list
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
You need to retrieve and assign the vGPU type that corresponds to the physical GPU device in your environment, and prepare the environment files to configure the Compute node for vGPU.
Procedure
- Install Red Hat Enterprise Linux and the NVIDIA GRID driver on a temporary Compute node and launch the node. For more information about installing the NVIDIA GRID driver, see Section 11.2.1, “Building a custom GPU overcloud image”.
On the Compute node, locate the vGPU type of the physical GPU device that you want to enable. For libvirt, virtual GPUs are mediated devices, or
mdev
type devices. To discover the supportedmdev
devices, enter the following command:ls /sys/class/mdev_bus/0000\:06\:00.0/mdev_supported_types/ cat /sys/class/mdev_bus/0000\:06\:00.0/mdev_supported_types/nvidia-18/description
[root@overcloud-computegpu-0 ~]# ls /sys/class/mdev_bus/0000\:06\:00.0/mdev_supported_types/ nvidia-11 nvidia-12 nvidia-13 nvidia-14 nvidia-15 nvidia-16 nvidia-17 nvidia-18 nvidia-19 nvidia-20 nvidia-21 nvidia-210 nvidia-22 [root@overcloud-computegpu-0 ~]# cat /sys/class/mdev_bus/0000\:06\:00.0/mdev_supported_types/nvidia-18/description num_heads=4, frl_config=60, framebuffer=2048M, max_resolution=4096x2160, max_instance=4
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
compute-gpu.yaml
file to thenetwork-environment.yaml
file:resource_registry: OS::TripleO::Compute::Net::SoftwareConfig: /home/stack/templates/nic-configs/compute.yaml OS::TripleO::ComputeGpu::Net::SoftwareConfig: /home/stack/templates/nic-configs/compute-gpu.yaml OS::TripleO::Controller::Net::SoftwareConfig: /home/stack/templates/nic-configs/controller.yaml #OS::TripleO::AllNodes::Validation: OS::Heat::None
resource_registry: OS::TripleO::Compute::Net::SoftwareConfig: /home/stack/templates/nic-configs/compute.yaml OS::TripleO::ComputeGpu::Net::SoftwareConfig: /home/stack/templates/nic-configs/compute-gpu.yaml OS::TripleO::Controller::Net::SoftwareConfig: /home/stack/templates/nic-configs/controller.yaml #OS::TripleO::AllNodes::Validation: OS::Heat::None
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the following parameters to the
node-info.yaml
file to specify the number of GPU-enabled Compute nodes, and the flavor to use for the vGPU-designated Compute nodes:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
gpu.yaml
file to specify the vGPU type of your GPU device:parameter_defaults: ComputeGpuExtraConfig: nova::compute::vgpu::enabled_vgpu_types: - nvidia-18
parameter_defaults: ComputeGpuExtraConfig: nova::compute::vgpu::enabled_vgpu_types: - nvidia-18
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteEach physical GPU supports only one virtual GPU type. If you specify multiple vGPU types in this property, only the first type is used.
Deploy the overcloud, adding your new role and environment files to the stack along with your other environment files:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
11.3. Creating the vGPU image and flavor 复制链接链接已复制到粘贴板!
To enable your cloud users to create instances that use a virtual GPU (vGPU), you can define a custom vGPU-enabled image, and you can create a vGPU flavor.
11.3.1. Creating a custom GPU instance image 复制链接链接已复制到粘贴板!
After you deploy the overcloud with GPU-enabled Compute nodes, you can create a custom vGPU-enabled instance image with the NVIDIA GRID guest driver and license file.
Procedure
Create an instance with the hardware and software profile that your vGPU instances require:
openstack server create --flavor <flavor> --image <image> temp_vgpu_instance
(overcloud) [stack@director ~]$ openstack server create --flavor <flavor> --image <image> temp_vgpu_instance
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Replace
<flavor>
with the name or ID of the flavor that has the hardware profile that your vGPU instances require. For information on default flavors, see Manage flavors. -
Replace
<image>
with the name or ID of the image that has the software profile that your vGPU instances require. For information on downloading RHEL cloud images, see Image service.
-
Replace
- Log in to the instance as a cloud-user. For more information, see Log in to an Instance.
-
Create the
gridd.conf
NVIDIA GRID license file on the instance, following the NVIDIA guidance: Licensing an NVIDIA vGPU on Linux by Using a Configuration File. Install the GPU driver on the instance. For more information about installing an NVIDIA driver, see Installing the NVIDIA vGPU Software Graphics Driver on Linux.
NoteUse the
hw_video_model
image property to define the GPU driver type. You can choosenone
if you want to disable the emulated GPUs for your vGPU instances. For more information about supported drivers, see Appendix A, Image configuration parameters.Create an image snapshot of the instance:
openstack server image create --name vgpu_image temp_vgpu_instance
(overcloud) [stack@director ~]$ openstack server image create --name vgpu_image temp_vgpu_instance
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Optional: Delete the instance.
11.3.2. Creating a vGPU flavor for instances 复制链接链接已复制到粘贴板!
After you deploy the overcloud with GPU-enabled Compute nodes, you can create a custom flavor that your cloud users can use to launch instances for GPU workloads.
Procedure
Create an NVIDIA GPU flavor. For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Assign a vGPU resource to the flavor that you created. You can assign only one vGPU for each instance.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
11.3.3. Launching a vGPU instance 复制链接链接已复制到粘贴板!
You can create a GPU-enabled instance for GPU workloads.
Procedure
Create an instance using a GPU flavor and image. For example:
openstack server create --flavor m1.small-gpu --image vgpu_image --security-group web --nic net-id=internal0 --key-name lambda vgpu-instance
(overcloud) [stack@virtlab-director2 ~]$ openstack server create --flavor m1.small-gpu --image vgpu_image --security-group web --nic net-id=internal0 --key-name lambda vgpu-instance
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Log in to the instance as a cloud-user. For more information, see Log in to an Instance.
To verify that the GPU is accessible from the instance, run the following command from the instance:
lspci -nn | grep <gpu_name>
$ lspci -nn | grep <gpu_name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
11.4. Enabling PCI passthrough for a GPU device 复制链接链接已复制到粘贴板!
You can use PCI passthrough to attach a physical PCI device, such as a graphics card, to an instance. If you use PCI passthrough for a device, the instance reserves exclusive access to the device for performing tasks, and the device is not available to the host.
Prerequisites
-
The
pciutils
package is installed on the physical servers that have the PCI cards. - The GPU driver is available to install on the GPU instances. For more information, see Section 11.2.1, “Building a custom GPU overcloud image”.
Procedure
To determine the vendor ID and product ID for each passthrough device type, run the following command on the physical server that has the PCI cards:
lspci -nn | grep -i <gpu_name>
# lspci -nn | grep -i <gpu_name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example, to determine the vendor and product ID for an NVIDIA GPU, run the following command:
lspci -nn | grep -i nvidia
# lspci -nn | grep -i nvidia 3b:00.0 3D controller [0302]: NVIDIA Corporation TU104GL [Tesla T4] [10de:1eb8] (rev a1) d8:00.0 3D controller [0302]: NVIDIA Corporation TU104GL [Tesla T4] [10de:1db4] (rev a1)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
To configure the Controller node on the overcloud for PCI passthrough, create an environment file, for example,
pci_passthru_controller.yaml
. Add
PciPassthroughFilter
to theNovaSchedulerDefaultFilters
parameter inpci_passthru_controller.yaml
:parameter_defaults: NovaSchedulerDefaultFilters: ['RetryFilter','AvailabilityZoneFilter','ComputeFilter','ComputeCapabilitiesFilter','ImagePropertiesFilter','ServerGroupAntiAffinityFilter','ServerGroupAffinityFilter','PciPassthroughFilter','NUMATopologyFilter']
parameter_defaults: NovaSchedulerDefaultFilters: ['RetryFilter','AvailabilityZoneFilter','ComputeFilter','ComputeCapabilitiesFilter','ImagePropertiesFilter','ServerGroupAntiAffinityFilter','ServerGroupAffinityFilter','PciPassthroughFilter','NUMATopologyFilter']
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To specify the PCI alias for the devices on the Controller node, add the following to
pci_passthru_controller.yaml
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf the
nova-api
service is running in a role other than the Controller, then replaceControllerExtraConfig
with the user role, in the format<Role>ExtraConfig
.-
To configure the Compute node on the overcloud for PCI passthrough, create an environment file, for example,
pci_passthru_compute.yaml
. To specify the available PCIs for the devices on the Compute node, add the following to
pci_passthru_compute.yaml
:parameter_defaults: NovaPCIPassthrough: - vendor_id: "10de" product_id: "1eb8"
parameter_defaults: NovaPCIPassthrough: - vendor_id: "10de" product_id: "1eb8"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To enable IOMMU in the server BIOS of the Compute nodes to support PCI passthrough, add the
KernelArgs
parameter topci_passthru_compute.yaml
:parameter_defaults: ... ComputeParameters: KernelArgs: "intel_iommu=on iommu=pt"
parameter_defaults: ... ComputeParameters: KernelArgs: "intel_iommu=on iommu=pt"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the overcloud, adding your custom environment files to the stack along with your other environment files:
(undercloud) $ openstack overcloud deploy --templates \ -e [your environment files] -e /home/stack/templates/pci_passthru_controller.yaml -e /home/stack/templates/pci_passthru_compute.yaml
(undercloud) $ openstack overcloud deploy --templates \ -e [your environment files] -e /home/stack/templates/pci_passthru_controller.yaml -e /home/stack/templates/pci_passthru_compute.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure a flavor to request the PCI devices. The following example requests two devices, each with a vendor ID of
10de
and a product ID of13f2
:openstack flavor set m1.large --property "pci_passthrough:alias"="t4:2"
# openstack flavor set m1.large --property "pci_passthrough:alias"="t4:2"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Create an instance with a PCI passthrough device:
openstack server create --flavor m1.large --image rhelgpu --wait test-pci
# openstack server create --flavor m1.large --image rhelgpu --wait test-pci
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Log in to the instance as a cloud user.
Install the GPU driver on the instance. For example, run the following script to install an NVIDIA driver:
sh NVIDIA-Linux-x86_64-430.24-grid.run
$ sh NVIDIA-Linux-x86_64-430.24-grid.run
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To verify that the GPU is accessible from the instance, enter the following command from the instance:
lspci -nn | grep <gpu_name>
$ lspci -nn | grep <gpu_name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To check the NVIDIA System Management Interface status, run the following command from the instance:
nvidia-smi
$ nvidia-smi
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow