I have malloc 12G gpu memory like this, but when I use nvidia-smi to check the gpu memory usage, it is only 4G. I couldn't understand.
size_t size = 6U * 1024 * 1024 * 1024 / 4;
int *devSrc;
int *devDest;
cudaMalloc((void**)&devSrc, sizeof(int) * size);
cudaMalloc((void**)&devDest, sizeof(int) * size);
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 2520767 C ...Test/cmake-build/cudaTest 4347MiB |
+-----------------------------------------------------------------------------+
when I change the variable size to 5U * 1024 * 1024 * 1024 / 4
, the nvidia-smi indicated the gpu memory usage deduced to 2G:
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 2521144 C ...Test/cmake-build/cudaTest 2299MiB |
+-----------------------------------------------------------------------------+