I found cudaMemGetInfo total memory is less than nvmlDeviceGetMemoryInfo total memory. I want to know why and what does 24152899584-23661248512=491651072=468.875MB means.
#include <iostream>
#include <nvml.h>
using namespace std;
int main() {
// 使用cudaMemGetInfo获取显存信息
size_t cuda_free = 0, cuda_total = 0;
cudaSetDevice(0);
cudaMemGetInfo(&cuda_free, &cuda_total);
cout << "cuda total:" << cuda_total << endl;
cout << "cuda free:" << cuda_free << endl;
cout << "cuda used:" << (cuda_total - cuda_free) << endl;
nvmlInit();
nvmlMemory_t mem;
nvmlDevice_t device;
nvmlDeviceGetHandleByIndex(0, &device);
nvmlDeviceGetMemoryInfo(device, &mem);
cout << "total:" << mem.total << endl;
cout << "free:" << mem.free << endl;
cout << "used:" << mem.used << endl;
nvmlShutdown();
return 0;
}
result: cudaMemGetInfo total memory is less than nvmlDeviceGetMemoryInfo total memory. And nvmlDeviceGetMemoryInfo total memory is equal to nvidia-smi result.
cuda total:23661248512
cuda free:23459921920
cuda used:201326592
total:24152899584
free:23459921920
used:692977664