显卡直通的配置教程网上非常零散,此文是自己的实践肝货。
GPU Passthrough
Enable the IOMMU
vim /etc/default/grub
Intel CPU
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on"
update-grub
Required Modules
这一步很重要,不同的pve版本,因为内核版本不同,所以这里的设置也不同,proxmox 6.2的设置参考了牛人的视频:https://www.youtube.com/watch?v=_fkKIMF3HZw
vim /etc/modules
vfio
vfio_pci
vfio_virqfd
IOMMU Interrupt Remapping
dmesg | grep 'remapping'
If you see one of the following lines:
“AMD-Vi: Interrupt remapping enabled” “DMAR-IR: Enabled IRQ remapping in x2apic mode” (‘x2apic’ can be different on old CPUs, but should still work) then remapping is supported.
Verify IOMMU Isolation
# find /sys/kernel/iommu_groups/ -type l
/sys/kernel/iommu_groups/0/devices/0000:00:00.0
/sys/kernel/iommu_groups/1/devices/0000:00:01.0
/sys/kernel/iommu_groups/1/devices/0000:01:00.0
/sys/kernel/iommu_groups/1/devices/0000:01:00.1
/sys/kernel/iommu_groups/2/devices/0000:00:02.0
/sys/kernel/iommu_groups/3/devices/0000:00:16.0
/sys/kernel/iommu_groups/4/devices/0000:00:1a.0
/sys/kernel/iommu_groups/5/devices/0000:00:1b.0
/sys/kernel/iommu_groups/6/devices/0000:00:1c.0
/sys/kernel/iommu_groups/7/devices/0000:00:1c.5
/sys/kernel/iommu_groups/8/devices/0000:00:1c.6
/sys/kernel/iommu_groups/9/devices/0000:00:1c.7
/sys/kernel/iommu_groups/9/devices/0000:05:00.0
/sys/kernel/iommu_groups/10/devices/0000:00:1d.0
/sys/kernel/iommu_groups/11/devices/0000:00:1f.0
/sys/kernel/iommu_groups/11/devices/0000:00:1f.2
/sys/kernel/iommu_groups/11/devices/0000:00:1f.3
/sys/kernel/iommu_groups/12/devices/0000:02:00.0
/sys/kernel/iommu_groups/12/devices/0000:02:00.1
/sys/kernel/iommu_groups/13/devices/0000:03:00.0
/sys/kernel/iommu_groups/14/devices/0000:04:00.0
All Xeon processor support them (E3,E5) excluding Xeon E3-1200.
其他设置
lspci | grep NVIDIA
81:00.0 3D controller: NVIDIA Corporation GP106 [P106-100] (rev a1)
# 81:00.0 就是gpu pcie id
# vendor id
lspci -n -s 81:00.0
81:00.0 0302: 10de:1c07 (rev a1)
echo "options vfio-pci ids=10de:1c07" > /etc/modprobe.d/vfio.conf
echo "blacklist radeon" >> /etc/modprobe.d/blacklist.conf
echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf
echo "blacklist nvidia" >> /etc/modprobe.d/blacklist.conf
重启机器
新建GPU Passthrough kvm虚拟机
建立kvm时,需要注意
bios: ovmf
machine: q35
等安装完成后,再关闭虚拟机,然后修改/etc/pve/nodes/pve/qemu-server/vm-id.conf
,加入
hostpci0: 81:00.0,pcie=1,x-vga=1
重启后,只能通过ssh登录进去,不能使用proxmox web ui中的vnc界面。