启用 CUDA GPU 在 VM 下工作

Omr*_*mri 13 nvidia virtualbox cuda

我已将图形适配器连接到我的 Ubuntu 14.10 服务器。我正在使用 VirtualBox,需要在 VM 下启用对 GPU 的访问。GPU 在服务器上工作,但不在 VM 上。

$ sudo lshw -C video
  *-display               
       description: VGA compatible controller
       product: NVIDIA Corporation
       vendor: NVIDIA Corporation
       physical id: 0
       bus info: pci@0000:84:00.0
       version: a1
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress vga_controller bus_master cap_list rom
       configuration: driver=nvidia latency=0
       resources: irq:151 memory:fa000000-faffffff memory:f0000000-f7ffffff memory:f8000000-f9ffffff ioport:f000(size=128) memory:fb000000-fb07ffff
Run Code Online (Sandbox Code Playgroud)

我已经根据以下说明安装了 Guest Additions: 如何在 VirtualBox VM 中安装 Guest Additions?

另外,我浏览了这个安装指南

还有这个

当我cat /proc/driver/nvidia/version按照上一个链接尝试时,什么也没发生。nvidia文件夹不存在

这是我尝试从 VM 访问 GPU 时遇到的错误:

modprobe: ERROR: could not insert 'nvidia_340': No such device
Error using gpuArray
No supported GPU device was found on this computer. To learn more about supported GPU devices, see <a href="matlab:web('http://www.mathworks.com/gpudevice','-browser')">www.mathworks.com/gpudevice</a>.
Error in main (line 2)

parallel:gpu:device:NoCUDADevice
Run Code Online (Sandbox Code Playgroud)

请指教。

bai*_*ain 12

除非您使用PCI passthrough,否则 VirtualBox 不会将主机 GPU 直接暴露给来宾。你可以试试,但它仍然是实验性的,可能不起作用。

直接使用 Linux 主机而不是尝试在 VM 中执行此操作会容易得多。如果您出于某种原因确实需要一个容器,请尝试 LXC(请参阅从 docker 容器中使用 GPU的答案)。