宿主机系统:esxi6
虚拟机系统:ubuntu16.04
显卡型号:GTX1070
需求:使用esxi虚拟出一台机器,虚拟出来的这台机器使用宿主机的显卡
首先需要在esxi界面中设置显卡直通,设置方法为:
使用浏览器登录esxi的web界面,在主机——管理——硬件——PCI设备——找到GTX1070后勾选——点击 显卡直通——最后把宿主机(也就是物理机)重启,步骤如下图:

上图中PCI设备中的第一个GTX1070就是显卡,紧接着应该是GTX1070上带的声卡,那就都选中吧!
调整esxi虚拟机的配置:
右击虚拟机——编辑设置——添加其它设备——PCI设备——选择GTX1070后保存即可,如下图:




最后一张图中,预留所有内存,如果不点击此选项,添加PCI设备后启动电源可能遇到问题。
显卡添加后,在虚拟机中安装显卡驱动
虚拟机中操作
1 2 3 4 |
apt-get install software-properties-common
add-apt-repository ppa:graphics-drivers /ppa
apt-get install nvidia-367
reboot
|
重启后执行命令:
报错:
1 |
Unable to determine the device handle for GPU 0000:0B:00.0: Unknown Error
|

解决:
宿主机中操作:
找到虚拟机的vmx文件,在其中添加内容
hypervisor.cpuid.v0 = "FALSE"
然后重启宿主机
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[root@localhost:~] df -h
Filesystem Size Used Available Use% Mounted on
VMFS-5 3.8T 12.5G 3.8T 0% /vmfs/volumes/datastore1 (7)
vfat 249.7M 8.0K 249.7M 0% /vmfs/volumes/70cb307a-40abe180-5fc5-9676290f20e8
vfat 4.0G 6.4M 4.0G 0% /vmfs/volumes/59b7beaa-2fe55e21-1523-1866daf3f486
vfat 249.7M 172.6M 77.1M 69% /vmfs/volumes/6b542e7d-36108b49-6650-c7db5e16a932
vfat 285.8M 203.6M 82.2M 71% /vmfs/volumes/59b7be71-74239e59-f059-1866daf3f486
[root@localhost:~] ls /vmfs/volumes/datastore1 \ \(7\) /new/new .vmx
/vmfs/volumes/datastore1 (7) /new/new .vmx
[root@localhost:~] tail -2 /vmfs/volumes/datastore1 \ \(7\) /new/new .vmx
cleanShutdown = "FALSE"
hypervisor.cpuid.v0 = "FALSE"
[root@localhost:~] reboot
esxi的reboot重启特别慢,可以手动重启,或者在浏览器中在电源选项中重新引导
[root@localhost:~] shutdown .sh
[root@localhost:~] reboot
|
参考:
http://blog.csdn.net/lixiaoguang20/article/details/53669253
https://devtalk.nvidia.com/default/topic/982322/linux/nvidia-smi-reports-unable-to-determine-the-device-handle-for-gpu/
另一个报错:
1 2 3 |
Unable to determine the device handle for GPU 0000:01:00.0: Unable to communicate with GPU because it is insufficiently powered.
This may be because not all required external power cables are
attached, or the attached cables are not seated properly.
|
解决:
显卡的电源线没插好
参考:
https://devtalk.nvidia.com/default/topic/946729/cuda-setup-and-installation/tesla-k40-nvidia-smi-error-can-acute-t-communicate-with-gpu/
1 2 3 4 5 6 7 8 |
This suggests that that the K40 is not properly connected to the power supply:
Sorry, my stupid mistake. Now, i read the datasheet ...
the reason for malfuction was the missing 8-pin ATX-Connector.
I only connected two 6-pin connectors. Thanks to Nvidia,
good papers.
thanks to txbob.
|
esxi重启命令(暂时没试过,不过esxi中好像没有shutdown命令):
1 2 3 |
reboot -f
halt
shutdown
|
本文转自 f_066 51CTO博客,原文链接:http://blog.51cto.com/ganmu/1964823,如需转载请自行联系原作者