Matlab GPU计算

use*_*243 2 matlab cuda gpu nvidia

我想要一个代码,用于检查计算机上我设计的软件(GUI)是否使用CUDA-Core图形卡(Nvidia)进行处理.得到'真实之后; 从中获取价值,我的软件激活了一些加速过程的功能.

谢谢.

Dev*_*-iL 5

你可以使用这个功能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
Run Code Online (Sandbox Code Playgroud)

(注意:您可以通过简单的点引用访问不同的属性,例如,ans.MultiprocessorCount将给出7.)

另请参阅以下页面:

  1. MATLAB中心文章

  2. 帮助#1 - GPUDevice类

  3. 帮助#2 - 识别并选择GPU设备

编辑

我刚刚在没有安装CUDA驱动程序的计算机上测试了这个.我得到的是以下异常(实际上是由current()GPUDevice类的方法引发的):

...'
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.
Run Code Online (Sandbox Code Playgroud)

出于这个原因,我建议首先围绕gpuDevice一个try-catch块,只有当它成功时,继续进行检查parallel.gpu.GPUDevice.isAvailable(1).

我的答案还没有涵盖的情况,例如具有多个GPU的设置(例如非CUDA板载1 +附加CUDA卡)或没有CUDA GPU的系统,但安装了CUDA驱动程序.对于多GPU情况,您还应该使用以下方法: parallel.gpu.GPUDevice.countparallel.gpu.GPUDevice.select(idx).