Check about CUDA-capable GPU

Hi Guys,

I wanted to write a little app which shows me the general informations about my GPU. The idea itself is easy enough yet the beginning is not working perfectly. First, i went with this:

cudaDeviceProp dev_prop;

int dev;

cudaGetDeviceProp(&dev);

if(dev == 0)

   printf("No CUDA-capable device found");

else

   printf("%d device(s) found", dev);

The method itself should be good, written down is textbooks about the topics. I asked a bunch of people who have computers with no NVIDIA GPU in it to try the app, and the output about the number of devices were like 12 (in most case), 4063588 and a some other random (?) numbers. So this method is not good at all. It detects there is a device when dev is anything but 0. Then:

cudaDeviceProp dev_prop;

int dev;

cudaError_t check = cudaGetDeviceProp(&dev);

if(check == cudaSuccess)

   printf("%d device(s) found", dev);

else

   printf("No CUDA-capable device found");

This one is better, at least it does not throw random numbers, but also, it does not detect a lot of NVIDIA GPU-s, mostly older ones, but ones with CUDA support (e.g. 8600GS, 8800GT, etc.). My first thought was it has something to do with compute-capability (1.1), but it does not, becouse 1-2 guys with 8800 GTS (also with CC of 1.1) comfirmed that my app is working just fine. So i really don’t understand the situation here. You have to have the CUDA toolkit installed to run an app like this? Or it requires something else?

Thank You and as always, sorry for my english.

you should ship the cudart_xx_xx_xx.dll with your application with which it has been built. This makes sure that all runtime functions without gpu stuff in it work like expected.

but first of all, in case the stuff you postet is everything you wrote: int dev is uninitialized and the only reason it works at least sometimes is, that the value at it’s memory address is zero which is the first device.

use cudaGetDevice(&dev) first.

to check for a cuda card you have some more possibilities:

cudaGetDeviceProp - check for the cc, in case there’s nothing it’s set to 9999 by the function.
cudaGetRuntimeVersion - checks the runtime dll/so revision
cudaGetDriverVersion - important in case you want to run “real” gpu stuff

Sorry, in my first comment, i wanted to write cudaGetDeviceCount(&dev) instead of cudaGetDeviceProp(&dev). But there was the right one in the code(the count). I don’t know what the cudaGetDevice have to do with anything, becouse it simply returns the one working and what i want to do is to check if there is one. I tried but it does not seems to be working. Can you write down the full code, or is it just something like this?

int dev;

	

cudaError_t check = cudaGetDevice(&dev);

if(check == cudaSuccess)

    printf("OK");