I’m currently making my own custom GPU report and am using torch.cuda.max_memory_allocated(device_id)
to get the maximum memory that each GPU uses. However, I’ve noticed that this number is different from when I run nvidia-smi
during the process.
According to the documentation for torch.cuda.max_memory_allocated
, the output integer is in the form of bytes. And from what I’ve searched online to convert the number of bytes to the number of gigabytes, you should divide it by 1024 ** 3
. I’m currently doing round(max_mem / (1024 ** 3), 2)
Am I doing the calculation wrong, or am I misunderstanding how torch.cuda.max_memory_allocated
works entirely? The memory allocated I’ve observed from one GPU during the entire process was aroudn 32GB, but torch.cuda.max_memory_allocated(0) / (1024 ** 3)
returns aroudn 13.5GB.