Is cudaGetDeviceCount really working? cudaGetDeviceCount seems not to work

Hi,

I’m trying to use cudaGetDeviceCount in order to check the availability of my NVIDIA 8800 GTX card. As I’ve only one card I expect that function to return either 0 or 1.

Maybe I’m not understanding very well the concept of “availability” but my point of view is that one device (card) is available if there’s no other kernel running on it. However, if there is one kernel running on the GPU and I call to cudaGetDeviceCount from another application, that function always returns 1, meaning the card is available when in fact it isn’t.

I’m doing some research on runtime adaptation and I need to check whether the GPU is being used or is free. Is cudaGetDeviceCount the way to check for that kind of “availability”? Otherwise, is there something else I could use?

Thanks in advance,
Victor

cudaGetDeviceCount tells you how many GPUs in your system support CUDA. Not what they are currently doing. I have not found any possibility to check (using CUDA APIs only) whether there is a kernel running. So you will need a global variable in your program that is set accordingly.

The only thing you can do is to check whether CUDA has been initialized. Call any driver API function. It will return CUDA_ERROR_NOT_INITIALIZED if there is no CUDA process that has called cuInit() yet. So if your system shuts down all computing threads after doing the work, this might be enough for you.

Peter