2

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.

1 Answer 1

5

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:

  1. MATLAB Central article

  2. Help #1 - GPUDevice class

  3. Help #2 - Identify and Select a GPU Device

Edit

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).

Sign up to request clarification or add additional context in comments.

8 Comments

from your edited information, when we use try-catch what should we insert in catch part? I don't want my program return an exception or something like that.
I suppose you should use an equivalent code that will run on the CPU or CPUs (using matlabpool,parfor and so on).
More information : I have a check box in my program. It is 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.
So what's the question\problem? How to correctly set the value of the checkbox? (I don't see why the user should be able to change this manually, unless he wants to force a CPU compution)
As you said you code return a error in a computer that there isn't any CODA-enabled graphic card in it. true true? So I think I should use try-catch. in try I should Enable check box and in catch mode I should Disable it?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.