llama.cppOut of memory
unable to allocate CUDA0 buffer (llama.cpp)
The message
unable to allocate CUDA0 buffer
What it means
llama.cpp could not reserve room for the model's weights on that device. The device name follows your backend: CUDA0, ROCm0, Vulkan0 or Metal.
Why it happens
- The weights alone are larger than the free memory on that device — before any context is added.
- Too many layers were forced onto the card with
-ngl. - Another process already holds part of the card.
How to fix it
- Compare the file size with your card in the VRAM calculator; the weights are roughly
params × bits ÷ 8. - Download a smaller level of the same model, or let llama.cpp choose the layer split by not passing
-ngl. - Free the card: stop other servers (
nvidia-smion NVIDIA,rocm-smion AMD shows what is using it).
Check the size before changing flags
Most memory errors are a size problem. Put the model, quant level, context and your card into the VRAM calculator: if it is red there, no flag will make it fit.
Guides that cover this
Related errors
Checked against
Message text read from source on 2026-10-26.