DoraCloud for Proxmox桌面云上启用NVIDIA Tesla P4的vGPU功能


Proxmox virtualization environment,简称PVE,是一个开源免费的基于linux的企业级虚拟化方案,功能不输专业收费的VMware。简单的说,PVE是一个基于Debian的linux系统,内置了一套虚拟机管理工具,并提供了web管理页面,让我们可以非常简单的通过网页管理虚拟机。

DoraCloud是一套多平台、一体化、分布式的桌面虚拟化方案。基于开放架构,支持多种虚拟化平台(Hyper-V,VMware,Proxmox,XenServer),多种桌面协议(RDP,PCoIP,SPICE)。采用All-in-One的设计模式和虚拟设备的部署方式。

NVIDIA Tesla P4单精度运算能力将达到5.5FLOPS,每秒可进行22万亿次计算,其拥有2560个流处理器,搭配8GB GDDR5显存。

服务器配置:i7-8700,32G,1TB nvme,配置Tesla P4显卡。

本文描述在服务器上部署 Proxmox、DoraCloud,并创建带有vGPU的虚拟桌面的过程。

1、下载安装Proxmox 5.4.1

  推荐中科大( USTC)的源下载 ISO,然后使用 rufus 制作 启动U盘。  https://mirrors.ustc.edu.cn/proxmox/iso/proxmox-ve_5.4-1.iso  

2、修改中科大源,更新

替换中科大的源,更新升级系统。 

cp /etc/apt/sources.list /etc/apt/sources.list.backup
sed -i 's|^deb http://ftp.debian.org|deb https://mirrors.ustc.edu.cn|g' /etc/apt/sources.list
sed -i 's|^deb http://security.debian.org|deb https://mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list

mv /etc/apt/sources.list.d/pve-enterprise.list /etc/apt/sources.list.d/pve-enterprise.list.bak
CODENAME=`cat /etc/os-release |grep PRETTY_NAME |cut -f 2 -d "(" |cut -f 1 -d ")"`
echo "deb https://mirrors.ustc.edu.cn/proxmox/debian $CODENAME pve-no-subscription" > /etc/apt/sources.list.d/pve-no-subscription.list

#更新
apt update && apt dist-upgrade -y

 安装DKMS 依赖包

#安装 DKMS 依赖包
apt install pve-headers dkms pve-headers-4.15.18-12-pve -y

3、启用 IOMMU

服务器为Intel 处理器,通过如下脚本启用IOMMU,如果是AMD处理器,配置有差异。

# 复制如下脚本,启用IO-MMU

# /etc/default/grub 的GRUB_CMDLINE_LINUX_DEFAULT,增加 intel_iommu=on iommu=pt
sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="quiet"/GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt"/g' /etc/default/grub

update-grub

# 加载 vfio vfio_iommu_type1 vfio_pci vfio_virqfd 4个Modules
echo vfio >> /etc/modules
echo vfio_iommu_type1 >> /etc/modules
echo vfio_pci >> /etc/modules
echo vfio_virqfd >> /etc/modules


echo "options vfio_iommu_type1 allow_unsafe_interrupts=1" > /etc/modprobe.d/iommu_unsafe_interrupts.conf
echo "options kvm ignore_msrs=1" > /etc/modprobe.d/kvm.conf
echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf

update-initramfs -u
reboot 


执行完毕脚本,会自动重启服务器,然后查看日志,确认 IOMMU已经启用。

root@pveserver:~# dmesg | grep -e DMAR -e IOMMU
[ 0.000000] ACPI: DMAR 0x0000000079A48648 0000A8 (v01 INTEL EDK2 00000002 01000013)
[ 0.000000] DMAR: IOMMU enabled
[ 0.004000] DMAR: Host address width 39
[ 0.004000] DMAR: DRHD base: 0x000000fed90000 flags: 0x0
[ 0.004000] DMAR: dmar0: reg_base_addr fed90000 ver 1:0 cap 1c0000c40660462 ecap 19e2ff0505e
[ 0.004000] DMAR: DRHD base: 0x000000fed91000 flags: 0x1
[ 0.004000] DMAR: dmar1: reg_base_addr fed91000 ver 1:0 cap d2008c40660462 ecap f050da

4、安装DKMS 和 NVIDIA 内核驱动程序

#下载nvidia 驱动
wget http://www1.deskpool.com:9000/software/NVIDIA-Linux-x86_64-460.32.03-grid.run
wget http://www1.deskpool.com:9000/software/NVIDIA-Linux-x86_64-460.32.04-vgpu-kvm.run

chmod +x NVIDIA-Linux-x86_64-460.32.04-vgpu-kvm.run

#安装驱动
./NVIDIA-Linux-x86_64-460.32.04-vgpu-kvm.run -dkms 

为了让DoraCloud桌面云系统能够使用nvidia 的GPU资源,需要对Proxmox 5.4 打一个补丁。 该补丁对Proxmox的 API进行了增强。

wget http://www1.deskpool.com:9000/software/patch.tar.gz
tar -zxvf patch.tar.gz  -C /

NVIDIA 驱动安装成功后,运行如下命令,重启Proxmox 服务器。

systemctl daemon-reload
reboot

系统启动后,检查日志,确认 vgpu 驱动已经启动。  可以看到不同类型的vGPU ,后续计划为桌面配置的vGPU TYPE为 0x3f(十进制63),型号为P4-1Q

root@pveserver:~# cat /var/log/syslog |grep P4
Nov 22 21:29:17 pveserver nvidia-vgpud: VGPU Type 0x47: GRID P4-1B Class: NVS
Nov 22 21:29:17 pveserver nvidia-vgpud: VGPU Type 0x3f: GRID P4-1Q Class: Quadro
Nov 22 21:29:17 pveserver nvidia-vgpud: VGPU Type 0x40: GRID P4-2Q Class: Quadro
Nov 22 21:29:17 pveserver nvidia-vgpud: VGPU Type 0x41: GRID P4-4Q Class: Quadro
Nov 22 21:29:17 pveserver nvidia-vgpud: VGPU Type 0x42: GRID P4-8Q Class: Quadro
Nov 22 21:29:17 pveserver nvidia-vgpud: VGPU Type 0x43: GRID P4-1A Class: NVS
Nov 22 21:29:17 pveserver nvidia-vgpud: VGPU Type 0x44: GRID P4-2A Class: NVS
Nov 22 21:29:17 pveserver nvidia-vgpud: VGPU Type 0x45: GRID P4-4A Class: NVS
Nov 22 21:29:17 pveserver nvidia-vgpud: VGPU Type 0x46: GRID P4-8A Class: NVS
Nov 22 21:29:17 pveserver nvidia-vgpud: VGPU Type 0x9d: GRID P4-2B Class: NVS
Nov 22 21:29:17 pveserver nvidia-vgpud: VGPU Type 0xd6: GRID P4-2B4 Class: NVS
Nov 22 21:29:17 pveserver nvidia-vgpud: VGPU Type 0xf3: GRID P4-1B4 Class: NVS
Nov 22 21:29:17 pveserver nvidia-vgpud: VGPU Type 0x121: GRID P4-8C Class: Compute
Nov 22 21:29:17 pveserver nvidia-vgpud: VGPU Type 0x120: GRID P4-4C Class: Compute

为了验证针对Proxmox API生效,可以使用如下命令查看一下。 增强后的API,可以显示 mdev设备的 name 字段。 如果你的Proxmox名字不是 pveserver,请修改成你的PVE主机名。

root@pveserver:~# pvesh get /nodes/pveserver/hardware/pci/01:00.0/mdev
┌───────────┬─────────────────────────────────────────────────────────────────────────────────────────┬─────────────┬────────────┐
│ available │ description                                                                             │ name        │ type       │
├───────────┼─────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼────────────┤
│         1 │ num_heads=4, frl_config=60, framebuffer=8192M, max_resolution=7680x4320, max_instance=1 │ GRID P4-8Q  │ nvidia-66  │
├───────────┼─────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼────────────┤
│         1 │ num_heads=1, frl_config=60, framebuffer=8192M, max_resolution=1280x1024, max_instance=1 │ GRID P4-8A  │ nvidia-70  │
├───────────┼─────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼────────────┤
│         1 │ num_heads=1, frl_config=60, framebuffer=8192M, max_resolution=4096x2160, max_instance=1 │ GRID P4-8C  │ nvidia-289 │
├───────────┼─────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼────────────┤
│         2 │ num_heads=1, frl_config=60, framebuffer=4096M, max_resolution=4096x2160, max_instance=2 │ GRID P4-4C  │ nvidia-288 │
├───────────┼─────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼────────────┤
│         2 │ num_heads=1, frl_config=60, framebuffer=4096M, max_resolution=1280x1024, max_instance=2 │ GRID P4-4A  │ nvidia-69  │
├───────────┼─────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼────────────┤
│         2 │ num_heads=4, frl_config=60, framebuffer=4096M, max_resolution=7680x4320, max_instance=2 │ GRID P4-4Q  │ nvidia-65  │
├───────────┼─────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼────────────┤
│         4 │ num_heads=4, frl_config=45, framebuffer=2048M, max_resolution=5120x2880, max_instance=4 │ GRID P4-2B  │ nvidia-157 │
├───────────┼─────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼────────────┤
│         4 │ num_heads=1, frl_config=60, framebuffer=2048M, max_resolution=1280x1024, max_instance=4 │ GRID P4-2A  │ nvidia-68  │
├───────────┼─────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼────────────┤
│         4 │ num_heads=4, frl_config=60, framebuffer=2048M, max_resolution=7680x4320, max_instance=4 │ GRID P4-2Q  │ nvidia-64  │
├───────────┼─────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼────────────┤
│         4 │ num_heads=4, frl_config=45, framebuffer=2048M, max_resolution=5120x2880, max_instance=4 │ GRID P4-2B4 │ nvidia-214 │
├───────────┼─────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼────────────┤
│         8 │ num_heads=1, frl_config=60, framebuffer=1024M, max_resolution=1280x1024, max_instance=8 │ GRID P4-1A  │ nvidia-67  │
├───────────┼─────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼────────────┤
│         8 │ num_heads=4, frl_config=60, framebuffer=1024M, max_resolution=5120x2880, max_instance=8 │ GRID P4-1Q  │ nvidia-63  │
├───────────┼─────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼────────────┤
│         8 │ num_heads=4, frl_config=45, framebuffer=1024M, max_resolution=5120x2880, max_instance=8 │ GRID P4-1B  │ nvidia-71  │
├───────────┼─────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼────────────┤
│         8 │ num_heads=4, frl_config=45, framebuffer=1024M, max_resolution=5120x2880, max_instance=8 │ GRID P4-1B4 │ nvidia-243 │
└───────────┴─────────────────────────────────────────────────────────────────────────────────────────┴─────────────┴────────────┘

5、部署 DoraCloud 

为了验证vGPU效果,我们在Proxmox 上部署DoraCloud。可以采用如下脚本在线安装 DoraCloud

cd /var/lib/vz/dump; wget -qO- https://dl.doracloud.cn/dpinstall.pl --referer https://doracloud.cn | perl

   

重启完毕后,然后浏览器登录 DoraCloud 管理后台,输入 账号  admin  DoraCloud,登录后台。

根据配置向导,完成DoraCloud的初始化配置。

 

接下来,我们下载支持vGPU的桌面模板。 win10LTSC2019GPU。

  然后创建桌面池,选择 win10LTSC2019GPU这个模板。 GPU型号选择 NVIDIA P4,vGPU类型选择 GRID P4-1Q

 配置桌面池内创建4个桌面。然后设置桌面池的绑定账号为 administrator  123456 。这样账号是windows7x64模板的Windows 账号。

启用绑定账号后,终端可以识别这个绑定账号,登陆桌面windows。

 桌面创建完毕后,可以在PVE中查看桌面虚拟的硬件配置,确认桌面虚拟机正常配置了 PCI device。

 接下来回到DoraCloud管理后台,添加用户,为用户分配桌面池。

6、登录桌面,验证vGPU效果

DoraCloud有多种登录方式,我们选择网页登录DoraCloud,输入用户账号  user01,密码123456。 然后打开一个 RDP 文件,输入管理员账号 administrator  123456,即可登录 windows 桌面。

 进入桌面后,通过dxdiag,查看系统的显卡,显示为 NVIDIA GRID P4-1Q。

接下来,可以进行3D性能的测试了。 推荐两个在线测试的网站。

基于WebGL的水母       https://akirodic.com/p/jellyfish/

基于WebGL的网页游戏    https://www.crazygames.com/