Constant RAM shortages on 24gb VRAM GPU. Is there a fix?
I'm just starting with local LLMs and I'm constantly running into OOM with my RAM. I use Qwen 3.6 27B Q4 MTP mostly but it happens even with the models on the smaller side (Qwen 3.5 9B). Why does it happen? My GPU is AMD RX7900XTX (24gb VRAM) and I have 16gb RAM. System is CachyOS. Backend is LM Studio with Vulkan llama.cpp. Qwen 3.6 prams I use:
- context length: 64000
- CPU thread pool size: 4
- GPU offload: max
- evaluation batch size: 512 (tried 256 but the model is very slow to load and process prompts)
- Offload KV cache to GPU memory: true
- unified KV cache: true
- mmap: true
- flash attention: true
- K and V cache quantization: IQ4_NL
LM Studio estimates memory usage as 20.95 GB but evidently it takes MUCH more because even RAM fills up to 100% quite quickly and LM Studio crashes. Is it normal? Should I just stick to smaller models?
About this post
- Posted
- Archived
- Score
- 3 · 71% up
- Kind
- Text
- ID
- 1tpjoos
25 comments
reduce the context length. GPU offload to RAM, but you need more RAM in general. 16gb doesnt leave you with much after your OS and bloatware gobble 2/3rd of that easily.
If you can, grab a used RX 580 or something along those lines and use that to drive your desktop. 7900XTX should happily run Qwen3.6-27B Q4 but if you want to get every last byte of usable VRAM out of it, you need to take the GUI workload off of it.
This. I freed up 4 gigs of VRAM switching to on board video (Radeon 2GB).
I have only 1 GPU slot in my mini case and my CPU doesn't have integrated graphics. But I think I can install a WM instead of Gnome to lighten up the GUI
That looks like normal pressure from context rather than a mystery crash, tbh. When I hit this pattern, the model estimate did not include every host allocation, cache behavior, and loading spike, so 16 GB system memory got crushed fast. I would drop the context hard first, maybe 8K or 16K, then raise it only after watching both memory pools during load and prompt processing. If you want to keep larger contexts, a 64GB system RAM kit is the most direct fix. Smaller batches can help stability, but they will not turn 16 GB into enough headroom for that setup.
Context. For general AI usage switch to Qwen3.6 35B A3B Q5 or greater and just use your 27 billion for coding, pure coding. You can run the 35 billion model. It's an Moe and you can fit max context. I think it's 262k so I run it on an 8 GB card. I get 40 tokens a second and I have 132k context so that one's good for fleshing out ideas, messing around, doing agentic work.
If you want to do the coding on the 27 billion, reduce your context down to 32k and do it in pieces.
Thanks! I'll try that
You can use q8 for kv also. This will let you 2x your 27b context.
I found MTP models give me these big spikes in RAM usage, they go away fast but cause stuttering and OOM very easily. The normal model is slower but it doesn't do this.
Oh, nice clue! Thanks!
Let me know if it helps, I was wondering if it was just me
What CPU do you have?
I have the same GPU, with RAM offloading enabled, and i route my video through my iGPU (7950X3D)
I have Ryzen 5 3600X, so no integrated graphics unfortunately
Idk if this works on windows but on mac I brought up mactop to watch my ram/gpu usage as models load and I use them to find out what was making them crash.
Context length changes how much ram loads but I wouldnt want lower than 64k context personally.
Qwen3.6 27B Q4 is tight in 24GB of VRAM. You may need to look at "nvtop" or the Windows equivalent to see what programs are using VRAM. You may also need to quit programs, etc. Even with all that, you may only wind up with 128k context.
It will work, but there's no margin for error.
disable mmap
This sounds like llama.cpp is caching everything and filling up ram
Don't use LM Studio. Just use llama.cpp's llama-server directly.
I have a 7900XTX. No issues with 64GB system ram. You need system ram that's at least 30% more than your VRAM because of loading the model itself and the k/v cache needed for the session.
What are the benefits of using llama.cpp directly? And is DDR4 memory okay for this? Looking at the responses, I consider buying a 32gb kit now. But I have Ryzen 5 3600X CPU, so only DDR4 is available for me
LM studio adds a bunch of stuff on top of llama-cpp. You also incur overhead running a GUI. In your case, you need every single byte you can squeeze. Having command line opens the door to a whole set of options not available in LM studio GUI
DDR4 is fine. I'm on a 5600X which uses DDR4 for my dedicated inference server. My particular set up sits at 30GB system RAM before loading a model into the GPU.
3600X is pretty long in the tooth though. You should see improvement with 16+ 32GB of RAM but if you were planning to do other stuff on the same machine while the LLM is running, the 3600X is going to struggle.
Sounds glitchy to me. Are you running rocm? Have you tried both Vulkan and rocm?
Tried both Vulkan and ROCm. ROCm loads excruciatingly slow, so I prefer Vulkan for now. I use unsloth ggufs but will try something else too, thanks!
I mean thats basicly what i run just under the 24gb after i run webui and tts. U gaming? Lol
One option is to trade-off speed for capacity. Sell your 7900 and with a bit of cash, you can get three 7800XT cards.