cudaGetDeviceCount() returning 1, while cudaMalloc() returning 38(1.e., cudaErrorNoDevice) on MAC. W


Im runnning CUDA code on MAC using Xcode.

My Hardware details:

OS: MAC OS X Leopard
System: iMAC intell
CUDAToolKit: 2.2
CUDADriver: dont know ( actually there is no driver on NVIDIA website to downoad cudaDriver for MAC OS. )
GPU Card: 8800 GS

int dCount;
cudaGetDeviceCount( &dCount );

cudaGetDeviceCount() is returning 1. ( Which means one device is present ).

but when I use cudaMalloc(),

int* iPtr;
cudaError error = cudaMalloc( (void**)&iPtr, sizeof(int)*2 );

it is returning 38, which means “No CUDA device available”.

Why is it so? what I am missing here?.

cudaGetDeviceCount() directly returns an error code, not the device count. The device count is returned with a single parameter (int-pointer).

You are actually receiving an error (1 = cudaErrorMissingConfiguration)…

int dCount;

cudaGetDeviceCount( &dCount );

I mean , here dCount is 1 after executing the above code.

int* iPtr;

cudaError error = cudaMalloc( (void**)&iPtr, sizeof(int)*2 );

here I got “error” as “cudaErrorNoDevice” after executing above code.

In the CUDA Reference Manual, search for cudaErrorNoDevice. (Hint: it’s near the top of page 12)

yeah, cudaGetDeviceCount(&value) putting 1 in value even when there’s no device is pretty dumb and should be fixed in the future.


When there is no device, cudaGetDeviceCount() always returns “1” – standing for emulation device.

Just compile your code with “-deviceemu” and this will work just fine