主控端系統:esxi6
虛拟機系統:ubuntu16.04
顯示卡型号:GTX1070
需求:使用esxi虛拟出一台機器,虛拟出來的這台機器使用主控端的顯示卡
首先需要在esxi界面中設定顯示卡直通,設定方法為:
使用浏覽器登入esxi的web界面,在主機——管理——硬體——PCI裝置——找到GTX1070後勾選——點選 顯示卡直通——最後把主控端(也就是實體機)重新開機,步驟如下圖:
<a href="https://s3.51cto.com/wyfs02/M02/06/71/wKiom1m4jOyCVLo2AAL32oT4vPY672.png" target="_blank"></a>
上圖中PCI裝置中的第一個GTX1070就是顯示卡,緊接着應該是GTX1070上帶的聲霸卡,那就都選中吧!
調整esxi虛拟機的配置:
右擊虛拟機——編輯設定——添加其它裝置——PCI裝置——選擇GTX1070後儲存即可,如下圖:
<a href="https://s3.51cto.com/wyfs02/M01/A5/22/wKioL1m4kGjhTLAHAAG14z247a8630.png" target="_blank"></a>
<a href="https://s1.51cto.com/wyfs02/M01/06/71/wKiom1m4kJPzt1BOAAObbPIUfEg374.png" target="_blank"></a>
<a href="https://s2.51cto.com/wyfs02/M01/A5/22/wKioL1m4kGvR-mUnAAFuBMexGlE255.png" target="_blank"></a>
<a href="https://s3.51cto.com/wyfs02/M02/A5/22/wKioL1m4kG_zrPA_AAJy21OzW-o648.png" target="_blank"></a>
最後一張圖中,預留所有記憶體,如果不點選此選項,添加PCI裝置後啟動電源可能遇到問題。
顯示卡添加後,在虛拟機中安裝顯示卡驅動
虛拟機中操作
<code>apt-get </code><code>install</code> <code>software-properties-common</code>
<code>add-apt-repository ppa:graphics-drivers</code><code>/ppa</code>
<code>apt-get </code><code>install</code> <code>nvidia-367</code>
<code>reboot</code>
重新開機後執行指令:
<code>nvidia-smi</code>
報錯:
<code>Unable to determine the device handle </code><code>for</code> <code>GPU 0000:0B:00.0: Unknown Error</code>
<a href="https://s4.51cto.com/wyfs02/M01/06/72/wKiom1m4ksPQHqdQAABkF6zPm4I694.png" target="_blank"></a>
解決:
主控端中操作:
找到虛拟機的vmx檔案,在其中添加内容
hypervisor.cpuid.v0 = "FALSE"
然後重新開機主控端
<code>[root@localhost:~] </code><code>df</code> <code>-h</code>
<code>Filesystem Size Used Available Use% Mounted on</code>
<code>VMFS-5 3.8T 12.5G 3.8T 0% </code><code>/vmfs/volumes/datastore1</code> <code>(7)</code>
<code>vfat 249.7M 8.0K 249.7M 0% </code><code>/vmfs/volumes/70cb307a-40abe180-5fc5-9676290f20e8</code>
<code>vfat 4.0G 6.4M 4.0G 0% </code><code>/vmfs/volumes/59b7beaa-2fe55e21-1523-1866daf3f486</code>
<code>vfat 249.7M 172.6M 77.1M 69% </code><code>/vmfs/volumes/6b542e7d-36108b49-6650-c7db5e16a932</code>
<code>vfat 285.8M 203.6M 82.2M 71% </code><code>/vmfs/volumes/59b7be71-74239e59-f059-1866daf3f486</code>
<code>[root@localhost:~] </code><code>ls</code> <code>/vmfs/volumes/datastore1</code><code>\ \(7\)</code><code>/new/new</code><code>.vmx</code>
<code>/vmfs/volumes/datastore1</code> <code>(7)</code><code>/new/new</code><code>.vmx</code>
<code>[root@localhost:~] </code><code>tail</code> <code>-2 </code><code>/vmfs/volumes/datastore1</code><code>\ \(7\)</code><code>/new/new</code><code>.vmx</code>
<code>cleanShutdown = </code><code>"FALSE"</code>
<code>hypervisor.cpuid.v0 = </code><code>"FALSE"</code>
<code>[root@localhost:~] reboot</code>
<code>esxi的reboot重新開機特别慢,可以手動重新開機,或者在浏覽器中在電源選項中重新開機</code>
<code>[root@localhost:~] </code><code>shutdown</code><code>.sh</code>
參考:
<a href="http://blog.csdn.net/lixiaoguang20/article/details/53669253" target="_blank">http://blog.csdn.net/lixiaoguang20/article/details/53669253</a>
<a href="https://devtalk.nvidia.com/default/topic/982322/linux/nvidia-smi-reports-unable-to-determine-the-device-handle-for-gpu/" target="_blank">https://devtalk.nvidia.com/default/topic/982322/linux/nvidia-smi-reports-unable-to-determine-the-device-handle-for-gpu/</a>
另一個報錯:
<code>Unable to determine the device handle </code><code>for</code> <code>GPU 0000:01:00.0: Unable to communicate with GPU because it is insufficiently powered.</code>
<code>This may be because not all required external power cables are</code>
<code>attached, or the attached cables are not seated properly.</code>
顯示卡的電源線沒插好
<a href="https://devtalk.nvidia.com/default/topic/946729/cuda-setup-and-installation/tesla-k40-nvidia-smi-error-can-acute-t-communicate-with-gpu/" target="_blank">https://devtalk.nvidia.com/default/topic/946729/cuda-setup-and-installation/tesla-k40-nvidia-smi-error-can-acute-t-communicate-with-gpu/</a>
<code>This suggests that that the K40 is not properly connected to the power supply:</code>
<code> </code>
<code>Sorry, my stupid mistake. Now, i </code><code>read</code> <code>the datasheet ...</code>
<code>the reason </code><code>for</code> <code>malfuction was the missing 8-pin ATX-Connector.</code>
<code>I only connected two 6-pin connectors. Thanks to Nvidia,</code>
<code>good papers.</code>
<code>thanks to txbob.</code>
esxi重新開機指令(暫時沒試過,不過esxi中好像沒有shutdown指令):
<code>reboot -f</code>
<code>halt</code>
<code>shutdown</code>
<a href="https://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&externalId=2074702" target="_blank">https://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&externalId=2074702</a>
本文轉自 f_066 51CTO部落格,原文連結:http://blog.51cto.com/ganmu/1964823,如需轉載請自行聯系原作者