amdgpu: count GTT in per-process memory usage#492
Open
rborkow wants to merge 1 commit into
Open
Conversation
Per-process memory only read drm-memory-vram, but the device-level accounting sums both the VRAM and GTT heaps. On integrated GPUs nearly all allocations live in GTT, so processes reported ~0 while the device showed gigabytes used (observed on a Radeon 890M: llama-server held 24.1 GiB in drm-memory-gtt and 5 MiB in drm-memory-vram). Count both pools, resolving the existing TODO. Candidate for an upstream PR. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Per-process memory on amdgpu only reads the
drm-memory-vramfdinfo key.On integrated GPUs, nearly all allocations live in the GTT heap, so the
process list reports ~0 memory while the device-level metrics show
gigabytes in use. This resolves the existing TODO at the parse site
(
// TODO: do we count "gtt mem" too?).Measured on a Ryzen AI 9 HX 370 / Radeon 890M (gfx1150, kernel 6.18),
with a 24 GB LLM loaded by ollama's llama-server:
nvtop showed the device at 24.3/48.0 GiB used, but attributed only
5 MiB to the process — and
gpu_mem_usageread 0%.Change
Count
drm-memory-gtt(and the legacygtt memkey) together withVRAM in
parse_drm_fdinfo_amd, accumulating both intogpu_memory_usage. This matches the device-level accounting, whichalready sums both heaps via
amdgpu_query_info(total_memory/used_memory= vram + gtt). With numerator and denominator nowmeasuring the same thing,
gpu_mem_usagepercentages become coherent:the process above reports 24.1 GiB / 50%, agreeing with the device
total.
Behavior change on discrete GPUs
A process's reported memory now includes its GTT usage (host RAM mapped
for the GPU) on dGPUs as well. I'd argue this is consistent — the
device-level metric already includes GTT, and both heaps are GPU-mapped
memory — but if you'd prefer to keep dGPU semantics unchanged, I'm happy
to rework this to add GTT only when
static_info->integrated_graphicsis set.
Testing
Verified on the Radeon 890M above (before: ~0 per process; after:
per-process totals match device totals under a 24 GB workload).