Syllo / nvtop

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

amdgpu: free_memory calculation can result in negative free memory #333

Open kkartaltepe opened 4 days ago

kkartaltepe commented 4 days ago

From https://github.com/Syllo/nvtop/blob/6e91c745cd051d902fc57e9195068df03eb192bb/src/extract_gpuinfo_amdgpu.c#L714-L719

Dumping the values on my machine gives

Gpu: AMD Radeon 780M
Gpu clock: 800Mhz
Mem clock: 2800Mhz
Gpu util: 18%
Mem util: 112%
Mem total: 603979776 B
Mem used: 522059776 B
Mem free: -76898304 B

Perhaps this is an amdgpu issue though as I would expect the memory_info.vram.usable_heap_size > memory_info.vram.heap_usage, but this doesnt seem to be the case. Though im not sure this is exposed in the UI anywhere so maybe its not a big deal.

kkartaltepe commented 4 days ago

https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c#L752-L757 appears to be the source of the calculation, i think the pin memory here is getting double counted when free space is calculated this way. So it is most appropriate to just do total_heap_size - heap_usage.