I want a code that check the computer that my designed software (GUI) is working on it using a CUDA-Core graphic card (Nvidia) or not. So after getting 'true; value from it, my software activate some features for accelerating process.
Thanks.
You could use the function gpuDevice. For me I get the following output:
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
(Note: you can access the different properties by simple dot reference, e.g. ans.MultiprocessorCount will give 7.)
Also see the following pages:
I just tested this on a computer that doesn't have the CUDA driver installed. What I get is the following exception (that is actually thrown by the current() method of the GPUDevice class):
...'
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.
For this reason I suggest first surrounding gpuDevice with a try-catch block and only if it was successful, proceeding with checks like parallel.gpu.GPUDevice.isAvailable(1).
There are still cases not covered by my answer, such as setups with more than one GPU (such as an non-CUDA on-board one + add-on CUDA card) or systems without a CUDA GPU, but that have CUDA drivers installed. For multi-GPU cases you should also use the methods:
parallel.gpu.GPUDevice.count and parallel.gpu.GPUDevice.select(idx).
try-catch what should we insert in catch part? I don't want my program return an exception or something like that.matlabpool,parfor and so on).Enable when GPU-computing is available in a system and it is Disable when there isn't anyCODA-Core graphic card in system, So I only want check availability of CODA-Core` graphic card in the system.try-catch. in try I should Enable check box and in catch mode I should Disable it?