Proxmox VE 虚拟群晖 gvt-g人脸识别解决方案

群晖照片的人脸识别需要Intel 核显在正确的 gpu 位置,能正常使用的位置是0000:00:02.0,只有在这个位置人脸识别功能正常工作,在Proxmox VE固定这个位置有下面机子方式。

一、直接映射位置

直接映射位置需要机型选择 i440fx,然后在conf配置中加入 args:-set device.hostpci(ID值).addr=0x02 -set device.vga.addr=0x10 ,如下图

image-20220514215836848

然后用vi编辑器打开虚拟机的配置文件,这里我的虚拟id是102,因此输入

vi /etc/pve/qemu-server/102.conf

上图圆圈选的显示为hostpci0,在args:行加入 args:-set device.hostpci0.addr=0x02 -set device.vga.addr=0x10

image-20220514220535087

然后保存重新启动群晖即可。

二、使用pl脚本挂载位置

机型选择 i440fx不如q35能获得最佳性能,那就使用pve 提供的脚本功能,它允许为 VM 运行特殊脚本。

首先确保在 虚拟机硬件配置中删除 GVT的pcie设备 并机型选择 q35。

使用命令复制示例脚本到新位置

cp /usr/share/pve-docs/examples/guest-example-hookscript.pl /var/lib/vz/snippets/dsm.pl

然后使用VI编辑脚本

vi /var/lib/vz/snippets/dsm.pl

然后在 pre-start部分,按照以下内容增加代码

if ($phase eq 'pre-start') {

    # First phase 'pre-start' will be executed before the guest
    # is started. Exiting with a code != 0 will abort the start

    print "$vmid is starting, doing preparations.\n";
    system("echo 9a5b4b67-bed5-4768-8af0-03ee9c227571 > /sys/devices/pci0000:00/0000:00:02.0/mdev_supported_types/i915-GVTg_V5_2/create");
    # print "preparations failed, aborting."
    # exit(1);

image-20220514221614271

再在 post-stop部分,增加代码

system("echo 1 > /sys/devices/pci0000:00/0000:00:02.0/9a5b4b67-bed5-4768-8af0-03ee9c227571/remove");

image-20220514221649141

然后用vi编辑器打开虚拟机的配置文件,这里我的虚拟id是102,因此输入

vi /etc/pve/qemu-server/102.conf

增加配置内容

args: -device vfio-pci,addr=0x02,sysfsdev=/sys/devices/pci0000:00/0000:00:02.0/9a5b4b67-bed5-4768-8af0-03ee9c227571
hookscript: local:snippets/dsm.pl

image-20220514221900838

然后保存重新启动群晖即可。

Last modification:May 14th, 2022 at 10:21 pm
如果觉得我的文章对你有用,请随意赞赏