CUDA kernel calls or runtime memory allocation calls can sometimes fail due to insufficient memory. The real-time memory usage on the CUDA device can be tracked by using applications like GPU-Z.
If you want to know the exact device memory usage at particular points in your program, the cudaMemGetInfo runtime call can be used. It returns the free and total memory in bytes. Subtract the free from total to get your memory usage:
size_t avail; size_t total; cudaMemGetInfo( &avail, &total ); size_t used = total - avail; cout << "Device memory used: " << used << endl;
Tried with: CUDA 3.2