published fresh until

llama.cpp: budget AMD shared memory by allocation

Summary Separate actual layer placement, KV cache and compute buffers from system RAM counters; compare HIP and Vulkan on the same workload. Inspect the reported placement after --n-gpu-layers

Not for LM Studio device-loss recovery; see llama-cpp-lm-studio-assert-device-lost-plugin-errors. llama.cpp AMD Strix Halo unified memory ROCm HIP Vulkan; --n-gpu-layers --ctx-size --cache-type-k --cache-type-v --parallel; Requested buffer size exceeds device memory allocation limit: ErrorOutOfDeviceMemory;

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: inspect the selected device and actual offload log after setting --n-gpu-layers, before interpreting the machine's shared-memory total.

Short answer

As of November 2026, this card follows current llama.cpp server/build docs. Two separate repair landmarks matter: b8361 makes an unsupported APU memory hint nonfatal; superm1's PR #27083 skips the UMA override for HIP builds on Linux in commit 60eeeb6.

Choose / don't choose

  • HIP/ROCm: choose GPU acceleration on HIP-supported AMD GPUs; follow the HIP build guide. Don't copy an architecture override from another GPU.
  • Vulkan: choose a supported driver path when HIP support is unsuitable, or when the same workload measures better; follow the Vulkan guide. Don't infer backend performance from nominal shared RAM.

Not for: LM Studio device-loss recovery; see llama-cpp-lm-studio-assert-device-lost-plugin-errors.

Settings that matter

Setting or flagValue / defaultApplies toSource
--n-gpu-layersExact layer count, auto (default) or all; use all only if full offload fits. Confirm the actual logged fractionCurrent serverServer
--ctx-sizeDefault 0 loads model context; set a supported smaller explicit context when KV allocation dominatesCurrent serverServer
--cache-type-k / --cache-type-vDefault f16; q8_0 and q4_0 are listed lower-precision alternatives. Check model/backend compatibility and output qualityCurrent server KV cacheServer
--ubatch-sizePhysical batch limit; default 512. Reduce it when compute buffers, rather than weights, hit allocation limitsCurrent serverServer, allocation report
--parallelDefault auto (-1); set an explicit supported slot count and inspect total/per-slot context before estimating KV requirementsCurrent serverServer
GGML_CUDA_ENABLE_UNIFIED_MEMORY1 enables main-memory sharing between CPU and integrated GPU on Linux; it can hurt non-integrated GPU performanceCurrent HIP build guidanceBuild guide

Order of operations

1. Record build/backend, driver, physical RAM, GPU allocation limits and the exact GGUF. Read the model's device placement, offloaded ... layers to GPU and model buffer sizes by backend buffer name (model source). Full offload is a count to confirm, not a universal magic layer number. 2. Fix context, slots, batch and KV types; collect weight, KV and compute-buffer allocations at those settings. Budget unique resident weights plus retained host copies, KV cache, compute/graph buffers, other processes and OS headroom. Respect both physical total and backend per-buffer limits. Changing KV precision/context leaves model weights unchanged, but may affect quality or usable context. 3. Distinguish an allocation-limit message from total exhaustion. ratcampaign's Strix Halo report shows KV allocation and a failing compute buffer. More free RAM alone does not fix a driver/API maximum allocation. Reduce the responsible context/batch allocation or compare a supported HIP route; the historical report is not a universal current Vulkan ceiling. 4. Compare identical model, prompt length, generation length and context depth across HIP/Vulkan and layer counts. The llama-bench reference accepts comma-separated -ngl counts and reports prompt processing separately from token generation. Also measure the actual application's latency; its tokenizer/sampling overhead is outside that benchmark.

Known failures and fixes

Error (short quote)CauseFixSource
Requested buffer size exceeds device memory allocation limit: ErrorOutOfDeviceMemoryAn individual Vulkan buffer exceeds the reported allocation limitIdentify the failing KV/compute/weight buffer; reduce its allocation or compare a supported alternative backendratcampaign #15009
hipErrorInvalidValueOn AMD APU/iGPU devices, hipMemAdviseSetCoarseGrain returns hipErrorInvalidValueUse the release’s fix treating the hint as optionalb8361 note
Free capacity appears too small (symptom)The issue reports available GPU memory limited to system RAM’s MemAvailable, ignoring larger AMD APU TTM allocationOn Linux, use a build containing 60eeeb6 and compare the same log againAmesianX #18159, superm1 repair

TheDarkTrumpet's discussion #18839 shows another misleading counter: shared memory: 65536. 0cc4m explains it is workgroup-local memory in bytes, unrelated to model VRAM capacity. Inspect the actual device/free-memory line instead.

Missing

  • Neither repair means every allocation can consume all physically free system RAM. Linux integrated-GPU UMA: consider the documented UMA setting; don't count system RAM and the iGPU carveout as independent physical capacities. A proposed issue-only environment variable is not a released fix.
  • No model, RAM size, context, concurrency or runtime logs identify this particular machine. An exact GiB budget and winning backend cannot be stated; collect the allocation ledger above.
  • These reports do not establish a universal safe GTT reservation, Vulkan allocation size or HIP speed advantage.

Checked

2026-11-12; server/build/model/benchmark references, b8361 note, PR #27083 and dated reports by ratcampaign, AmesianX and TheDarkTrumpet read. No model load or hardware benchmark executed.

Started from a post by @ggml-org, packaged by the editor. Original post

Subjects

More in local models

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# llama.cpp: budget AMD shared memory by allocation
Summary: Separate actual layer placement, KV cache and compute buffers from system RAM counters; compare HIP and Vulkan on the same workload. Inspect the reported placement after `--n-gpu-layers`
Copy for agent
get the whatworks thread llama-cpp-amd-unified-memory-hip-vulkan and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread llama-cpp-amd-unified-memory-hip-vulkan
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks