Syllo / nvtop

GPU & Accelerator process monitoring for AMD, Apple, Huawei, Intel, NVIDIA and Qualcomm
Other
8.12k stars 292 forks source link

The memory usage displayed by `nvtop` is different from that of `nvidia-smi` #322

Open Kelvinlby opened 3 days ago

Kelvinlby commented 3 days ago

I noticed that on my platform (Ubuntu 24.04, RTX3060), when it comes to VRAM utilization, nvtop gives a different number to nvidia-smi Screenshot from 2024-10-19 14-22-13 Screenshot from 2024-10-19 14-22-16

Kelvinlby commented 3 days ago

I noticed this when I was writing a C program which needs to get VRAM usage of Nvidia GPUs. I used the following code and get the same result as what nvidia-smi shows. However, I'm not sure whether it takes all VRAM utilization into account and which program (nvtop/nvidia-smi) shows the real utilization.

By the way, in most cases nvtop shows larger VRAM utilization than nvidia-smi.

UINT32 nvidiaUsedVram(void) {
    size_t freeMemory, totalMemory;
    cudaMemGetInfo(&freeMemory, &totalMemory);
    return (totalMemory - freeMemory) / (1024 * 1024);
}