一、在BIOS中打开硬件辅助虚拟化功能支持
对于intel cpu , 在主板中开启VT‐x及VT‐d选项:
VT‐x为开启虚拟化需要
VT‐d为开启PCI passthrough
这两个选项㇐般在BIOS中Advance下CPU和System或相关条⽬中设置,例如 :
VT: Intel Virtualization Technology
VT‐d : Intel VT for Directed I/O
对于 amd cpu , 在主板中开启SVM及IOMMU选项
SVM为开启虚拟化需要
IOMMU为开启PCI passthrough二、确认内核支持iommu
cat /proc/cmdline | grep iommu
如果没有输出 , 则需要修改kernel启动参数
对于intel cpu
编辑 /etc/default/grub ⽂件 , 在 GRUB_CMDLINE_LINUX ⾏后⾯添加 :intel_iommu=on
例如 :GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root quiet intel_iommu=on"
如果没有 GRUB_CMDLINE_LINUX , 则使⽤ GRUB_CMDLINE_LINUX_DEFAULT10
更新grub: grub 2‐mk config ‐o /boot/grub 2/grub.cfg
如果是uefi启动,需要修改启动文件: grub 2‐mk config ‐o /boot/efi/EFI/centos/grub.cfg
reboot 重启机器
对于amd cpu
与intel cpu的区别为 , 添加的是 amd_iommu=on, 其他步骤㇐样三、确认GPU设备信息
查找显卡的Product ID 以及 Vendor ID:
# lspci -vnn | grep -i nvi
0c:00.0 VGA compatible controller [0300]: NVIDIA Corporation Device [10de:2204] (rev a1) (prog-if 00 [VGA controller]) Subsystem: NVIDIA Corporation Device [10de:1454]
0c:00.1 Audio device [0403]: NVIDIA Corporation Device [10de:1aef] (rev a1) Subsystem: NVIDIA Corporation Device [10de:1454]
其中[10de:2204]的10de为NVIDIA pci设备的vendor id, 2204为product id, 0c:00.0为设备地址四、配置nova-scheduler
在filter_scheduler中加⼊ Pci PassthroughFilter , 同时添加 available_filters = nova.scheduler.filters.all_filters
# vim /etc/kolla/config/nova.conf
# 添加新的块filter_scheduler
[filter_scheduler]
enabled_filters = RetryFilter,AvailabilityZoneFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter,AggregateCoreFilter,AggregateDiskFilter,DifferentHostFilter,SameHostFilter,PciPassthroughFilter
available_filters = nova.scheduler.filters.all_filters五、配置nova-api
# vim /etc/kolla/config/nova.conf
# 添加新的块pci
# 注意:如果是网卡"device_type ":"type-PF "。如果是gpu则"device_type ":"type-PCI"
[pci]
alias = { "vendor_id":"10de", "product_id":"2204", "device_type":"type-PCI","name":"Nvidia3090a" }
passthrough_whitelist = { "vendor_id": "10de", "product_id": "2204", "address": "0000:0c:00.0" }六、reconfigure nova组件
# kolla-ansible -i /etc/ansible/hosts -t nova deploy七、创建带GPU标签的flavor
# openstack flavor set FLAVOR-NAME --property pci_passthrough:alias =ALIAS:COUNT
ALIAS为GPU设备透传申明的名称
COUNT为GPU设备透传的数量
例如:
# openstack flavor set GPU-16C32G-e --property pci_passthrough:alias='Nvidia3090a:1'作者:束鹏 创建时间:2026-06-05 10:00
最后编辑:束鹏 更新时间:2026-06-15 17:34
最后编辑:束鹏 更新时间:2026-06-15 17:34