环境:
ESXi 7.6 (下载自网络,文件名为:ESXI670_Build13473784 By SPK.iso)
GeForce GTX 1070
Ubuntu 18.04.4
为什么特意写版本型号呢?实际证明,这个坑是ESXi的BUG,打了补丁后,就没坑了。
步骤:
其实网络上的步骤没问题,做记录如下:
1.登录ESXi web管理界面,主机/管理/硬件/PCI设备中,选中显卡,点击“切换直连”,重启服务器;
2. 进入菜单 虚拟机/虚拟机名/编辑,添加其他设备,选择PCI设备,选中显卡。启动虚拟机。
3. 软件安装驱动步骤, 然后重启。
# 如果提示找不到命令,请apt-get install ubuntu-drivers-common
root@xinbin:~# ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:0f.0 ==
modalias : pci:v000015ADd00000405sv000015ADsd00000405bc03sc00i00
vendor : VMware
model : SVGA II Adapter
manual_install: True
driver : open-vm-tools-desktop - distro free
== /sys/devices/pci0000:00/0000:00:15.0/0000:03:00.0 ==
modalias : pci:v000010DEd00001B81sv00007377sd00000000bc03sc00i00
vendor : NVIDIA Corporation
model : GP104 [GeForce GTX 1070]
driver : nvidia-driver-440 - third-party free recommended
driver : nvidia-driver-390 - distro non-free
driver : nvidia-driver-435 - distro non-free
driver : nvidia-driver-430 - distro non-free
driver : xserver-xorg-video-nouveau - distro free builtin
#根据提示,安装指定驱动,比如我安装的是
apt-get install nvidia-driver-440
4. 接着坑来了,也是其他网上资料没有提到的。驱动安装完了,先不要急着安装CUDA。先运行以下命令确认驱动是否正常
root@xinbin:~# nvidia-smi
Wed Mar 4 02:39:53 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.33.01 Driver Version: 440.33.01 CUDA Version: 10.2 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 1070 On | 00000000:03:00.0 Off | N/A |
| 47% 37C P8 15W / 160W | 1MiB / 8119MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
以上是正确的提示,如果遇到以下提示,那么恭喜你,进坑了。为了出坑,我用了几乎一天的时间。
root@xinbin:~# nvidia-smi
Unable to determine the device handle for GPU 0000:03:00.0: Unknown Error 解决这个问题,我尝试过很多方法,其实很简单,也是大多数博客提到的办法:
hypervisor.cpuid.v0 = FALSE
# 给虚拟机增加这个配置,不需要手工修改 .vmx 文件。
# 只需要在编辑/虚拟机选项/高级/编辑配置 中,添加这个参数即可。 如果一切OK,那么本文就没必要存在了。配置修改后,虚拟机无法启动了,提示 pref event create on cpu 0 failed with -2 。看来是上面加的配置出了问题。经过N多尝试,最后在国外网站上得到了提示,给ESXi打补丁。打完补丁后,一切OK,显卡正常工作了。
以下是补丁方法:
1. 在 https://my.vmware.com/group/vmware/patch#search 下载补丁,我下载的是update-from-esxi6.7-6.7_update03.zip.zip,这是一个累计更新包;(写完博客后,我把这个文件传到csdn)
2. 通过文件管理,上传此文件;
3. 启用ssh, 进入维护模式;
4. 使用ssh登录ESXi,运行以下命令
esxcli software vib install -d "/vmfs/volumes/datastore1/update-from-esxi6.7-6.7_update03.zip.zip"
5. 补丁安装完后,重启服务器。