Skip to content

LLM VRAM Calculator: How Much GPU Memory Do You Need?

Estimate the GPU memory a local LLM needs from its size, quantization, context length and parallel requests.

On this page

How much GPU memory do you need to run a large language model locally? Pick a model size, a quantization format and a context length below. The calculator estimates the VRAM for the model weights, the KV cache and runtime overhead, and shows which common GPUs can hold it.

– GB of VRAM needed

Model weights
–
KV cache
–
Runtime overhead
–

Fits on

    Estimates for Ollama and llama.cpp. vLLM reserves 90% of VRAM up front by default and uses the spare memory for more KV cache.

    How the Estimate Works

    The memory a model needs on the GPU has three parts:

    • Model weights: number of parameters × bits per weight ÷ 8. An 8B model at 16-bit precision needs about 15 GB; at Q4_K_M (about 4.85 bits per weight) it needs about 4.5 GB.
    • KV cache: the model’s working memory for the conversation. It grows with the context length and the number of parallel requests: 2 × layers × KV heads × head dimension × tokens × bytes per value. Llama 3.1 8B uses about 1 GB for an 8K context at FP16.
    • Runtime overhead: CUDA context, compute buffers and fragmentation. The calculator adds 0.5 GB plus 5% of the weights.

    Real usage varies by a few hundred megabytes between tools, drivers and model architectures, so leave some headroom. A result marked Tight uses more than 90% of the card and may fail with longer prompts.

    Quantization Formats Explained

    FormatBits per weightQualityUsed by
    FP16 / BF1616OriginalvLLM, Transformers
    Q8_0 / FP88–8.5Practically losslessllama.cpp, Ollama / vLLM
    Q6_K, Q5_K_M5.7–6.6Very close to originalllama.cpp, Ollama
    Q4_K_M~4.85Good; the usual defaultllama.cpp, Ollama
    AWQ / GPTQ 4-bit~4.25GoodvLLM
    Q3_K_M, Q2_K3.4–3.9Noticeably worsellama.cpp, Ollama

    Ollama’s default model tags are usually Q4_K_M. A larger model at Q4 generally beats a smaller model at Q8 of the same file size.

    How to Fit a Bigger Model

    • Shorten the context. Halving the context length halves the KV cache.
    • Quantize the KV cache. llama.cpp and Ollama support an 8-bit KV cache, and vLLM supports FP8. It halves KV memory with little quality loss.
    • Offload some layers to the CPU. llama.cpp (-ngl) and Ollama do this automatically when VRAM runs out. It works, but every layer on the CPU slows generation down.
    • Use two GPUs. llama.cpp splits layers across cards, and vLLM supports tensor parallelism (--tensor-parallel-size).

    Run the Model

    Once you know what fits, set up a runtime on Ubuntu 26.04 or 24.04:

    ToolBest forGuides
    OllamaEasiest setup, one user or a small teamUbuntu 26.04 · Ubuntu 24.04
    llama.cppFull control, CPU and mixed CPU/GPUUbuntu 26.04 · Ubuntu 24.04
    vLLMServing many users from a GPU serverUbuntu 26.04 · Ubuntu 24.04
    Open WebUIChat interface for any of the aboveUbuntu 26.04 · Ubuntu 24.04
    Back to top