Skip to content
Courses/Local MLOps and model deployment/VRAM and OOM: vLLM vs Ollama/llama.cpp

VRAM and OOM: vLLM vs Ollama/llama.cpp

Most local setups don't fail because the model is 'bad': they fail because it doesn't fit, because context blows up the KV cache, or because you're using a runtime built for concurrency when all you need is stability.

  • Separate weight memory, KV cache, context, and batch.
  • Decide when to use vLLM, Ollama, or llama.cpp.
  • Apply a fix path before buying new hardware.

Quick rule

  • Ollama: simpler and more stable for personal use, testing, and low concurrency.
  • llama.cpp: lots of control, GGUF, mixed CPU/GPU, and practical multi-GPU.
  • vLLM: throughput and concurrency when the model fits with headroom.
Terminal
# Watch GPU and memory while testing
nvidia-smi -l 1

# Ollama: check model, size, and effective context
ollama ps

# vLLM: start conservatively
python -m vllm.entrypoints.openai.api_server \
  --model Qwen/Qwen2.5-7B-Instruct \
  --max-model-len 4096 \
  --gpu-memory-utilization 0.85

Fix path before you give up

  • Lower `max-model-len`: long context consumes a lot of memory.
  • Try a smaller quant or a smaller model.
  • Reduce batch/concurrency.
  • Leave VRAM headroom: don't aim for 99% utilization.
  • If you need stability, try llama.cpp/Ollama before vLLM.
  • If you need concurrency, use vLLM but with a model that fits comfortably.
Terminal
# llama.cpp server with GGUF model
./llama-server \
  -m ./models/modelo-q4_k_m.gguf \
  --ctx-size 4096 \
  --n-gpu-layers 99 \
  --host 0.0.0.0 \
  --port 8080

Official sources

  • vLLM: Quantized KV Cache
  • Ollama: context length
  • llama.cpp: multi-GPU
Complete Aulafy mapSee how this lesson fits without leaving your path.

Complete Aulafy map

How all courses connect

This is not a checklist. Start with the foundation, choose an outcome, and go deeper only when your project needs more control.

  1. 1Understand
  2. 2Apply or build
  3. 3Operate with confidence
01

Choose an application

Turn the foundation into a visible outcome: a website, a business improvement, media, or an interactive experience.

Continue into the technical branch when you need to maintain code, data, or infrastructure.

02

Build with code

Prepare your environment, work with coding agents, and run models while keeping control of your projects.

This branch prepares you to design and operate reliable AI systems.

03

Take systems to production

Combine retrieval, agents, evaluation, security, deployment, and model adaptation when the problem requires it.

You do not need every course: choose the component your system needs and return as it grows.

View full catalogue