I’m getting incorrect total memory using cudaMemGetInfo function. I have 4 graphics cards: 3 of them (C2050) have 2.8 GB of global memory, and 1 (C2075) has 5.6 GB of global memory. When I use the C2075 card, the cudaMemGetInfo function reports only 2.8 GB of global memory. When I use the “totalGlobalMem” device property, it correctly reports 5.6 GB of global memory. Does anyone know why cudaMemGetInfo might be reporting incorrect total memory?
(1) Is the system running a 32-bit OS?
(2) Is the system running Windows, using the default WDDM driver (if so, what’s the amount of system memory on this platform) ?
(3) What is the version of CUDA and the version of the driver package ?
Make sure none of the API calls returns an error. The size parameters are all size_t, so I would suggest storing and printing them accordingly. Does the output change if you use the following program?
#include <stdio.h>
#include <stdlib.h>
// Macro to catch CUDA errors in CUDA runtime calls
#define CUDA_SAFE_CALL(call) \
do { \
cudaError_t err = call; \
if (cudaSuccess != err) { \
fprintf (stderr, "Cuda error in file '%s' in line %i : %s.\n",\
__FILE__, __LINE__, cudaGetErrorString(err) ); \
exit(EXIT_FAILURE); \
} \
} while (0)
int main (void)
{
cudaDeviceProp deviceProp;
CUDA_SAFE_CALL (cudaGetDeviceProperties(&deviceProp, 2));
size_t gpuGlobalMem = deviceProp.totalGlobalMem;
fprintf(stderr, "GPU global memory = %zu Bytes\n", gpuGlobalMem);
size_t freeMem, totalMem;
CUDA_SAFE_CALL (cudaMemGetInfo(&freeMem, &totalMem));
fprintf(stderr, "Free = %zu, Total = %zu\n", freeMem, totalMem);
return EXIT_SUCCESS;
}
If you still see wildly mismatching sizes reported with the code above, I would suggest filing a bug.
The driver team suggests to cycle (i.e. unload and reload) the kernel driver with
rmmod nvidia && modprobe nvidia
so you are working with a freshly loaded driver. We can’t think of anything that would cause the total memory size reported to differ between the two API calls, so a bug report seems in order. Sorry for the inconvenience. Bug reports can be filed via the registered develoepr website, as follows:
I just realized what the problem is. I had forgotten to set the device to 2 before calling the cudaMemGetInfo function. For this reason, it was reporting the total memory from the first GPU card, which only has 2.8 GB of global memory, instead of the 3rd GPU card, which has 5.6 GB of global memory. Now that I’m setting the correct GPU before calling cudaMemGetInfo function, I’m getting the correct results!