背景
NVIDIA vGPU软件在企业或数据中心的物理GPU(https://www.nvidia.cn/data-center/graphics-cards-for-virtualization/)上,可以创建虚拟GPU被kvm虚拟机共享,大大丰富了GPU的使用场景,提高了灵活性。
VGPU技术与消费级显卡是无缘的,黑客通过patch的手段,为普通NVIDIA显卡增加了支持,pascal,tuling这2代卡获得了广泛的支持,本文以GTX 1660 Super为例,演示vGPU的使用。
vGPU部署
平台选择
综合来看,Proxmox 7.3最佳。以前的版本配置较为复杂,7.4版本截至2023-04-15日,bug还比较多。
vGPU版本选择
社区最新版本15.1(https://github.com/justin-himself/NVIDIA-VGPU-Driver-Archive)
部署
Proxmox安装
常规安装即可,无特殊
vGPU-Unlock
1
2
|
git clone https://github.com/VGPU-Community-Drivers/vGPU-Unlock-patcher
git submodule --init update
|
1660 Super的pci id是10de:21c4,可以模拟成RTX 6000,首先修改patch.sh
1
|
vcfgclone ${TARGET}/vgpuConfig.xml 0x1E30 0x12BA 0x21C4 0x0000
|
然后放入NVIDIA vGPU驱动包
1
2
|
NVIDIA-Linux-x86_64-525.85.07-vgpu-kvm.run
NVIDIA-Linux-x86_64-525.85.05-grid.run
|
最后执行./patch.sh vgpu-kvm生成patch驱动并执行nvidia-install安装
windows虚拟机
- 创建虚拟机,添加声卡,virtio显卡,mdev pcie设备,常规安装即可。
- 系统装好后,安装NVIDIA vGPU windows guest驱动,开启远程桌面,parsec远程软件(比较快,支持60Hz)
- 禁用virtio显卡,parsec远程访问
Linux虚拟机
- 创建虚拟机,添加声卡,virtio显卡,mdev pcie设备,常规安装即可。
- 系统安装好以后,修改为root登录,开启ssh远程访问
vGPU license
vGPU需要license才能正常运作,否则20分钟以后性能将下降到1fps,严重影响使用,fastapi-dls项目提供了NVIDIA兼容的实现,支持vGPU 14.3之后的版本,docker方式使用最为简单。
1
2
3
4
5
6
7
8
9
10
11
|
WORKING_DIR=/opt/docker/fastapi-dls/cert
mkdir -p $WORKING_DIR
cd $WORKING_DIR
# create instance private and public key for singing JWT's
openssl genrsa -out $WORKING_DIR/instance.private.pem 2048
openssl rsa -in $WORKING_DIR/instance.private.pem -outform PEM -pubout -out $WORKING_DIR/instance.public.pem
# create ssl certificate for integrated webserver (uvicorn) - because clients rely on ssl
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout $WORKING_DIR/webserver.key -out $WORKING_DIR/webserver.crt
docker volume create dls-db
docker run -e DLS_URL=`hostname -i` -e DLS_PORT=443 -p 443:443 -v $WORKING_DIR:/app/cert -v dls-db:/app/database collinwebdesigns/fastapi-dls:latest
|
Linux
1
2
3
4
|
wget --no-check-certificate -O /etc/nvidia/ClientConfigToken/client_configuration_token_$(date '+%d-%m-%Y-%H-%M-%S').tok https://192.168.1.29/-/client-token
service nvidia-gridd restart
nvidia-smi -q | grep "License"
|
Windows
访问https://192.168.1.29/-/client-token,将下载到的文件放到C:\Program Files\NVIDIA Corporation\vGPU Licensing\ClientConfigToken目录内重启
Q & A
windows环境parsec无法自动运行
parsec依赖显卡才能正常运作,必须得先获取vGPU license,这也就是为什么先用RDP远程访问一次,parsec就可以正常工作了。
解决版本也很简单,开启windows自动登录功能
Linux环境glxgears帧率降为1fps
原因和windows类似,一旦屏幕关闭,性能就不正常了。
解决方法任选其一
- 系统自动登录,电源管理关闭屏幕电源管理,保持常量
- 配置xorg.conf,然后重启
1
2
3
4
5
6
7
|
edit the /etc/X11/xorg.conf file to set the options to disable DPMS and disable the screen saver.
a). In the Monitor section, set the DPMS option to false.
Option "DPMS" "false"
b). At the end of the file, add a ServerFlags section that contains option to disable the screen saver.
Section "ServerFlags"
Option "BlankTime" "0"
EndSection
|