Imran Khan
← Back to blog
Running Local AI Models with Ollama: Infrastructure Requirements by Model Size (7B to 70B+)
Ollamalocal LLMLLM inferencequantizationGGUFllama.cppVRAM requirementsRAM requirementsGPU inferenceCUDAMetalROCmMistralLlama 3Q4_K_MQ5_K_MQ8_0

Running Local AI Models with Ollama: Infrastructure Requirements by Model Size (7B to 70B+)

By ··18m read

Plan local LLM capacity with Ollama: weight-memory estimates, KV cache and concurrency costs, hardware compatibility, and a measurement procedure for 7B to 70B+ models.

Running an AI model locally can give you control over where prompts are processed and let you work without cloud access once model files are downloaded. It does not automatically beat cloud latency or cost: performance depends on your hardware, and hardware, power, and maintenance still cost money. Ollama packages model serving for macOS, Linux, and Windows, with inference paths including llama.cpp-derived components and hardware-specific backends.

This guide focuses on the part people most often get wrong: matching the model and quantization to your infrastructure. “Can my machine run a 13B model?” is rarely the right question; the right question is “Can my machine run this model, at this context length, with this quantization, at a throughput I consider usable?”

Below is a practical, infrastructure-first explanation—with examples—of how to plan local model deployments with Ollama from 7B through 70B+, and how CPU, RAM, GPU VRAM, quantization, and context length interact.

The hardware tiers are planning estimates for dense text models, not measured benchmarks or guaranteed minimums. Exact model architecture, quantization format, backend, prompt length, and concurrent requests matter more than the parameter label alone. Mixture-of-experts models also have different total-weight and active-compute budgets. Before buying hardware, reproduce your workload on the exact model and configuration.

What Ollama is doing under the hood (and why it matters)

Ollama pulls a model package (commonly GGUF-based for llama.cpp-compatible execution), allocates memory for:

  • Model weights (dominant factor, affected by parameter count and quantization),
  • KV cache (grows with context length and model size),
  • Runtime overhead (tokenization, buffers, threads, GPU kernels, etc.).

When you choose a model in Ollama (for example, a Llama- or Mistral-family variant), you’re implicitly choosing:

  1. Parameter count (7B, 8B, 13B, 14B, 33B, 34B, 70B, etc.).
  2. Quantization (Q2/Q3/Q4/Q5/Q8, or similar).
  3. Context length (e.g., 4k, 8k, 16k, 32k), which drives KV cache memory.
  4. Execution path (CPU-only or GPU-accelerated, depending on platform and build).

Those choices determine whether the model fits and whether it runs fast enough to be useful.

Model size vs. memory: the first-order approximation

A rough way to think about weight memory is:

  • FP16 weights: ~2 bytes per parameter (plus overhead), which is huge.
  • Quantized weights: fewer bits per parameter, commonly:
    • Q4 ≈ 4 bits/param (0.5 bytes/param),
    • Q5 ≈ 5 bits/param (0.625 bytes/param),
    • Q8 ≈ 8 bits/param (1 byte/param).

This is a lower-order estimate, not a capacity requirement. Real formats add scales, block metadata, and tensors kept at higher precision. The rough equation is parameters × bits_per_weight / 8; divide bytes by 1e9 for GB or 2^30 for GiB, and do not silently mix the units.

Rule of thumb for weights only (very approximate):

  • 7B at Q4: ~4–5 GB
  • 13B at Q4: ~8–10 GB
  • 33B/34B at Q4: ~18–22 GB
  • 70B at Q4: ~35–45 GB

Then add KV cache and runtime overhead.

For concrete package checks, the official library currently lists Llama 3.1 8B Q4_K_M at about 4.9 GB and Qwen 2.5 14B Q4_K_M at about 9.0 GB. Those are download sizes, not total runtime RAM/VRAM. Record the model ID and quantization with ollama list and ollama show <model> so later comparisons use the same artifact.

The KV cache: why context length can break “it fits” assumptions

Even if your weights fit in RAM/VRAM, large context can push you over the edge. KV cache scales with:

  • number of layers,
  • number of key/value heads and their head dimension (grouped-query attention can change the footprint substantially),
  • context length,
  • batch/parallelism,
  • precision used for KV and whether that backend supports a quantized cache.

You don’t need the exact formula to plan; you need the consequence:

  • Doubling context length (e.g., 4k → 8k) roughly doubles KV cache memory.
  • A larger parameter count does not determine KV cache size on its own. Compare architecture and cache configuration, not just 7B versus 70B.

For a conventional full-attention decoder, a useful illustrative cache estimate is 2 × layers × kv_heads × head_dim × cached_tokens × bytes_per_element × parallel_sequences. The 2 accounts for keys and values. Architectures with sliding-window, compressed, or nonstandard state need a different estimate. See the Ollama context documentation and inspect actual allocation rather than inferring it from advertised maximum context.

If you want long-context summarization (8k–32k), KV cache becomes a primary infrastructure driver, not just weights.

CPU-only vs GPU-accelerated: choosing the right bottleneck

CPU-only inference

CPU-only is viable and often pleasant for:

  • 7B/8B models at Q4/Q5,
  • 13B at Q4 on a strong desktop CPU,
  • single-user usage where your measured generation rate and time to first token are acceptable.

CPU-only becomes frustrating for:

  • 34B and above unless you accept very low throughput,
  • long contexts (KV cache bandwidth),
  • multi-user setups.

CPU inference bottlenecks are typically:

  • memory bandwidth,
  • vectorization (AVX2/AVX-512),
  • thread scheduling.

GPU-accelerated inference

GPU acceleration is usually about:

  • achieving higher token throughput,
  • keeping latency low at higher context lengths,
  • running bigger models (34B/70B) at usable speeds.

But it introduces a hard constraint:

  • VRAM capacity determines how much of the model + KV cache can reside on GPU.

If VRAM is insufficient, runtimes can offload some layers to GPU and keep the rest in RAM (hybrid offload). This can work well, but performance varies based on PCIe bandwidth and how much ends up ping-ponging.

Infrastructure tiers by model size (practical targets)

The following estimates assume one dense chat/instruction model, Q4-like weights, and one request with moderate context (4k–8k). RAM is total system capacity; a discrete GPU has a separate VRAM budget. An Apple Silicon machine shares one memory pool with the OS. No tier promises a specific token rate or answer quality.

Tier A: 7B–8B models (best “default local LLM” class)

Typical models: Llama 3.x 8B class, Mistral 7B class, similar.

Recommended hardware (comfortable):

  • RAM: 16 GB minimum; 32 GB preferred if you multitask or use long contexts.
  • CPU: modern 6–12 cores.
  • GPU (optional): 8–12 GB VRAM is nice but not required.

Quantization guidance:

  • Q4 is a common starting point, but it is neither the smallest format nor universally the fastest.
  • Q5 uses more memory and may reduce quantization loss; measure the difference on your tasks.
  • Q8 generally preserves weights more closely but consumes more memory. Tool-call and reasoning quality still require evaluation.

What “good” performance looks like:

  • CPU-only: often usable.
  • GPU: very responsive.

This is a useful starting size for mainstream machines, subject to backend support and available memory.

Tier B: 13B–14B models (heavier memory)

Examples: Llama 2 13B and Qwen 2.5 14B. Llama 3 and Llama 3.1 do not have a 13B release; check the actual model card instead of mixing family names and sizes.

Recommended hardware:

  • RAM: 32 GB is a comfortable planning target, not a hard minimum.
  • GPU: 12–16 GB VRAM for high GPU offload; 24 GB is excellent.
  • CPU: strong single-thread + good memory bandwidth matters.

Quantization guidance:

  • Q4 is common and workable.
  • Q5 is a good sweet spot if you have RAM/VRAM headroom.
  • Avoid overly aggressive quantizations (Q2/Q3) unless you must fit tight constraints.

Compare this tier against smaller newer or task-tuned models. More parameters do not guarantee a quality improvement for your task.

Tier C: 33B–34B models (serious local inference territory)

Typical models: 33B/34B class (varies by family).

Recommended hardware:

  • RAM: 64 GB recommended.
  • GPU: 24 GB can be a useful target for some Q4 models; it is not a minimum for partial acceleration or a guarantee of full offload. 48 GB provides more headroom.
  • CPU-only: possible but usually slow.

Quantization guidance:

  • Q4 is typically the entry point.
  • Q5 may be too large for many single-GPU setups once KV cache is included.

This is where “it loads” and “it’s usable” diverge dramatically. If your use-case is interactive chat, GPU offload is often the difference between acceptable and not.

Tier D: 70B+ models (high-end, multi-GPU or very large VRAM)

Typical models: Llama 70B class, similar.

Recommended hardware:

  • RAM: 128 GB if you plan to run large quantizations and long contexts; 64 GB can work for certain quantizations but becomes tight quickly.
  • GPU: 48 GB may fit some Q4 models with modest context and one request; it can be insufficient with long context or concurrency. Validate before relying on full offload. Multi-GPU memory distribution also has backend and bandwidth costs.
  • CPU-only: generally impractical for interactive use.

Quantization guidance:

  • Q4 variants are common for feasibility.
  • Q5/Q6 can be excellent but often push you into multi-GPU or huge VRAM territory.
  • Plan context length conservatively if VRAM is your constraint.

If you’re targeting 70B, you’re doing infrastructure planning in the same way you would for a small on-prem service, not a desktop tool.

Quantization choices in practice (Q4 vs Q5 vs Q8)

Quantization is not only about “will it fit?”; it affects:

  • response quality (especially reasoning consistency, instruction following, and niche domains),
  • speed (smaller weights can be faster due to cache and bandwidth),
  • task accuracy under your actual prompts and context lengths.

A practical heuristic for local Ollama usage:

  • Q4: a practical first candidate when memory is constrained.
  • Q5: compare when you have headroom; an uplift is model- and task-dependent.
  • Q8: use when you’re troubleshooting quality regressions or need maximal fidelity; otherwise it’s heavy.

If you’re on the edge of fit, compare a lower-bit quantization, a smaller model, and a shorter context. None universally preserves more quality than the others; evaluate the errors that matter to your application.

Context length planning: choose it intentionally

A common failure mode is choosing a big model and then quietly expecting 16k or 32k context to “just work.” Long context requires:

  • more KV cache memory,
  • more compute per token,
  • more time to prefill (processing the prompt).

Two practical patterns:

  1. Interactive chat: 4k–8k is usually plenty if you summarize and manage conversation.
  2. Document work (summarization/QA): consider smaller models with longer context, or chunking + retrieval (RAG), rather than forcing a huge model into massive context.

If you are building workflows around documents, it’s often better engineering to:

  • chunk text,
  • embed into a vector store,
  • retrieve relevant passages,
  • feed a smaller context window, than to brute-force 32k contexts on a large model.

Example setups (illustrative capacity targets)

Example 1: Laptop/dev machine, “I want local chat and coding help”

Target: 7B/8B Q4/Q5, 4k–8k context

  • RAM: 16–32 GB
  • GPU: optional; 8–12 GB VRAM may fit the model and a modest cache, but check available memory
  • Evaluate: response latency, coding-task accuracy, and valid tool calls rather than assuming all 8B models handle them reliably

Ollama usage:

ollama pull llama3.1:8b
ollama run llama3.1:8b

Example 2: Desktop workstation, “I want better reasoning without cloud”

Target: 13B/14B Q4/Q5, 8k context

  • RAM: 32–64 GB
  • GPU: 16–24 GB VRAM recommended
  • Evaluate: whether its task accuracy improves enough over the smaller model to justify latency and memory

Ollama usage:

ollama pull qwen2.5:14b
ollama run qwen2.5:14b

Example 3: Prosumer GPU box, “I want 34B-class locally”

Target: 34B Q4, 4k–8k context

  • RAM: 64 GB
  • GPU: 24 GB is a candidate for some Q4 models; 48 GB provides more headroom
  • Evaluate: full versus partial offload, time to first token, and task accuracy

Operational note: keep other GPU memory consumers low (browsers, electron apps, other GPU services), because fragmentation and background VRAM usage can cause sudden OOM failures.

Example 4: On-prem service, “70B for a small team”

Target: 70B Q4, moderate context, multi-user

  • RAM: 128 GB
  • GPU: size the model and per-request cache; 48 GB is not a blanket multi-user requirement
  • Evaluate: tail latency, queue behavior, and peak memory under expected concurrent prompts

Deployment note: local serving should include:

  • an authenticated gateway or private network boundary, with TLS when traffic leaves the host,
  • request limits,
  • logging with redaction,
  • model warm-up procedures,
  • and observability (latency/token metrics).

Serving models with Ollama (API-first workflows)

Ollama is often used as a local service rather than an interactive CLI. A typical pattern is:

  • start the Ollama daemon,
  • call the local HTTP API from your app.

Example text generation request using the documented /api/generate endpoint; /api/chat instead accepts a conversation’s messages. The following multiline curl syntax is for Bash/WSL:

curl http://localhost:11434/api/generate \
  -H "Content-Type: application/json" \
  -d '{
    "model": "llama3.1:8b",
    "prompt": "Explain the tradeoffs between Q4 and Q5 quantization for local inference.",
    "stream": false,
    "options": { "num_ctx": 4096, "num_predict": 256 }
  }'

From an infrastructure perspective, API usage introduces two immediate considerations:

  1. Concurrency: parallel requests can multiply KV cache allocation, while requests queued serially do not all allocate the same active cache. Set and measure parallelism deliberately.
  2. Latency variance: long prompts cause “prefill spikes,” so p95 latency can look worse than average.

If you’re building internal tools, shape prompts and limit context sizes explicitly to keep tail latencies under control.

The local API does not require authentication. Keep its default loopback binding for local use; changing OLLAMA_HOST or adding a tunnel/proxy can expose it. CORS is not authentication. Protect shared access with a private network or an authenticated gateway and request limits. Also distinguish downloaded local models from Ollama cloud models; use local artifacts and disable cloud features when your requirement is local-only processing.

Measure before declaring a setup usable

  1. Record OS, Ollama version, exact model ID, quantization, context, and parallelism.
  2. Run ollama ps during a request to inspect loaded memory, allocated context, and CPU/GPU split. Compare with OS/GPU monitoring and leave headroom for other processes.
  3. Run the representative prompt once cold and several times warm. Test the longest expected prompt, not only “Hello.”
  4. From non-streaming API responses, calculate generation tokens/second as eval_count / eval_duration * 1e9 (durations are nanoseconds). Report prompt-processing time and model-load time separately; neither is included in that generation rate.
  5. Repeat at expected concurrency, checking queue errors and p95 latency. A single successful request is not a capacity test.

No token-rate benchmark is claimed here. This procedure gives you evidence for your hardware rather than treating a parameter count as a performance result.

For a worked example, the local ticket-routing comparison records cold and warm latency, sampled memory, routing errors, and manual-review workload for typed decisions and JSON baselines. Its fixed models and synthetic tickets give you a method to adapt, not a capacity promise for your own queue.

Storage and model management considerations

Model files are large, and you’ll likely pull multiple variants while testing.

Practical planning:

  • 7B Q4: a few GB
  • 13B/14B Q4/Q5: commonly high single-digit to low double-digit GB; check the chosen artifact
  • 34B Q4: tens of GB
  • 70B Q4: dozens of GB

Give yourself:

  • at least 100–200 GB free if you intend to iterate,
  • fast SSD (NVMe) to reduce load times and improve swap behavior (though swapping during inference is still a bad time).

Operating system and accelerator backend notes

Ollama’s experience differs by platform because GPU backends differ:

  • macOS (Apple Silicon): unified memory means “VRAM vs RAM” is less rigid, but you still have a finite pool; large models compete with everything else in memory. Performance can be very good due to Metal acceleration paths.
  • Linux/Windows (NVIDIA): verify your GPU and driver against the support matrix.
  • Linux (AMD): ROCm support varies by GPU and distro; feasibility depends on driver stack maturity.
  • Windows: native Ollama supports GPU backends on supported hardware; WSL2 is an option, not a universal requirement. Docker GPU usage adds its own runtime setup. Check the current hardware support matrix, including ROCm/Vulkan platform details, before buying or configuring a GPU.

The key infrastructure point: don’t only spec “GPU TFLOPs.” For LLM inference, VRAM capacity and memory bandwidth are often more important than raw compute.

Troubleshooting “it’s slow” vs “it doesn’t fit”

Symptoms of not fitting (memory pressure)

  • process killed / OOM errors,
  • dramatic slowdowns when the OS starts swapping,
  • GPU out-of-memory during prompt prefill (often at longer contexts),
  • load succeeds but first long prompt fails.

Fixes:

  • lower quantization (Q5 → Q4),
  • reduce context length,
  • reduce concurrency,
  • ensure other apps aren’t consuming GPU memory,
  • move up a hardware tier (more RAM/VRAM).

Symptoms of “it fits but it’s slow”

  • low tokens/sec despite no OOM,
  • high CPU usage with poor throughput,
  • GPU underutilized because too little is offloaded.

Fixes:

  • increase GPU offload (when possible),
  • pick a smaller model class,
  • prefer Q4 for speed if quality remains acceptable,
  • reduce context length and prompt size,
  • ensure correct backend (CUDA/Metal) is being used by your environment.

External sources (references)