【发布时间】:2014-09-12 13:07:19
【问题描述】:
我想要一个代码来检查我设计的软件 (GUI) 是否使用 CUDA-Core 显卡 (Nvidia) 在计算机上运行。所以在得到'true;从中受益,我的软件激活了一些加速过程的功能。
谢谢。
【问题讨论】:
我想要一个代码来检查我设计的软件 (GUI) 是否使用 CUDA-Core 显卡 (Nvidia) 在计算机上运行。所以在得到'true;从中受益,我的软件激活了一些加速过程的功能。
谢谢。
【问题讨论】:
您可以使用函数gpuDevice。对我来说,我得到以下输出:
ans =
CUDADevice with properties:
Name: 'GeForce GTX 660 Ti'
Index: 1
ComputeCapability: '3.0'
SupportsDouble: 1
DriverVersion: 6
ToolkitVersion: 5.5000
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 2.1475e+09
FreeMemory: 1.7126e+09
MultiprocessorCount: 7
ClockRateKHz: 1019500
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
CanMapHostMemory: 1
DeviceSupported: 1
DeviceSelected: 1
(注意:您可以通过简单的点引用访问不同的属性,例如ans.MultiprocessorCount 将给出7。)
另请参阅以下页面:
我刚刚在没有安装 CUDA 驱动程序的计算机上对此进行了测试。我得到的是以下异常(实际上是由 GPUDevice 类的current() 方法抛出的):
...'
Error using gpuDevice (line 26)
There is a problem with the CUDA driver associated with this GPU device. See www.mathworks.com/gpudriver to find and install the latest
supported driver.
Caused by:
The CUDA driver could not be loaded. The library name used was 'nvcuda.dll'. The error was:
The specified module could not be found.
出于这个原因,我建议首先在gpuDevice 周围加上一个try-catch 块,并且只有在它成功的情况下,才继续进行parallel.gpu.GPUDevice.isAvailable(1) 之类的检查。
我的回答仍然没有涵盖某些情况,例如具有多个 GPU 的设置(例如非 CUDA 板载一个 + 附加 CUDA 卡)或没有 CUDA GPU 但具有 CUDA 的系统安装的驱动程序。对于多 GPU 情况,您还应该使用以下方法:
parallel.gpu.GPUDevice.count 和 parallel.gpu.GPUDevice.select(idx)。
【讨论】:
try-catch 时,我们应该在catch 部分插入什么?我不希望我的程序返回异常或类似的东西。
matlabpool、parfor 等等)。
Enable,当系统中没有CODA-Core显卡时是Disable,所以我只想检查系统中CODA-Core`显卡的可用性.