I would like to compute a c# function to test if my graphic card is enabled with CUDA. I know that the NVIDIA site responded by the knowledge of the model of the card and by looking at a list of enabled card at “CUDA GPUs - Compute Capability | NVIDIA Developer”. But I want to do it with a program. Is there an existing function with CUDA Library which does the job or not? And if not, how to do it?
Statically link cudart library to your application (which is the default)
Perform an innocuous CUDA runtime library call (such as cudaSetDevice(0))
Check the error code from the above call. If it is cudaSuccess, a CUDA capable GPU (at least one) is available, and properly installed. If it is not cudaSuccess, then a properly installed CUDA GPU is not available.
If cudaSuccess is returned in step 3 above, then you can do other cuda runtime api calls to determine how many GPUs are available, and what type they are.
The CUDA deviceQuery sample code generally covers all this.