On MAC: cudaGetDeviceCount() is returning cudaSuccess, but cudaMlloc() is returning cudaErrorNoDevic

Hi,

Following is my code to set init the cuda device

[b]int deviceCount;
cudaError error = cudaGetDeviceCount(&deviceCount );
if ( error != cudaSuccess )
return error;

if ( deviceCount < 1 )
return cudaErrorNoDevice;
else
cudaSetDevice(deviceCount-1);[/b]

Here cudaGetDeviceCount() is returning cudaSuccess.

below is the code for allocatimg memory…

int* iPtr;
int error = cudaMalloc( (void**)&iPtr, sizeof(int)*2);
if ( error == cudaSuccess )
error = cudaFree(iPtr);
else
return error;

Here cudaMalloc() is returning cudaErrorNoDevice.

What could be the reason? please help me.