ShVaSa Blog
DIY & Self-Hosting • 6 min read

What actually runs well with Ollama on a CPU server with 8–16 GB RAM

Published on 2026-11-05 by Sharath Japa, ShVaSa Lab Lead
diyselfhostingsystemsopen-source
Discuss on r/shvasa

Executive Summary

Running large language models (LLMs) on a CPU-only server with 8–16 GB of RAM is an exercise in severe constraint management. Unlike GPU-accelerated inference, where the bottleneck is often memory bandwidth or compute throughput, CPU inference on this hardware tier is bottlenecked by RAM capacity, memory bandwidth, and single-threaded performance. The "runnable" threshold is not defined by model size alone, but by the quantization level and the architectural efficiency of the model.

For 8 GB of RAM, the viable landscape is restricted to highly optimized, small language models (SLMs) such as Phi-3-mini, Gemma-2b, or Qwen2-1.5B, strictly in 4-bit or even 3-bit quantization. These models fit within the physical memory but leave negligible headroom for the operating system, context window expansion, and Ollama’s runtime overhead. For 16 GB of RAM, the ceiling expands to include 7B-parameter models (e.g., Llama-3-8B, Mistral-7B) in Q4_K_M quantization, provided the context window is managed aggressively.

Ollama, while user-friendly, introduces a specific memory footprint due to its Go-based runtime and underlying llama.cpp implementation. On low-memory systems, this overhead can cause out-of-memory (OOM) kills if the model selection is not precise. This analysis details the exact architectural trade-offs, quantization strategies, and configuration parameters required to achieve stable, low-latency inference on CPU-bound hardware within this memory envelope.

Implementation & Architecture

The core of Ollama’s CPU inference engine is llama.cpp, a C++ implementation that utilizes AVX/AVX2/AVX512 instructions for vectorization. On a CPU server, the system relies on RAM rather than VRAM. The architecture of inference involves loading the model weights into RAM, initializing the KV (Key-Value) cache for context, and executing matrix multiplications using the CPU’s ALU.

Memory Layout and Quantization

LLMs are typically trained in FP16 or BF16 precision. Running these on 8–16 GB RAM is impossible for models larger than ~3B parameters. Therefore, quantization is mandatory. Ollama uses GGUF format, which supports various quantization schemes:

The KV cache is the dynamic memory consumer. For a 7B model with a 4096 context window, the KV cache can consume 2–4 GB of RAM alone. On an 8 GB system, this leaves only ~4 GB for weights and OS, which is insufficient for Llama-3-8B. Thus, context window limits must be enforced at the API level.

Ollama Configuration for Low-Memory Systems

Ollama’s default configuration may attempt to load too much into memory. To stabilize performance on 8–16 GB RAM, specific environment variables and Modelfile adjustments are required.

YAML
# .ollama/config.json (or environment variables)
{
  "num_ctx": 2048,
  "num_batch": 512,
  "num_gpu": -1,
  "main_gpu": 0,
  "tensor_split": null,
  "num_thread": 0,
  "num_keep": 0,
  "seed": -1,
  "num_gqa": 0,
  "num_rank": 1,
  "num_streams": -1,
  "rope_freq_base": 0.0,
  "rope_freq_scale": 0.0,
  "no_kv_offload": false,
  "offload_kqv": true,
  "flash_attn": false,
  "log_level": "info",
  "log_disable": false,
  "log_json": false,
  "mlock": false,
  "mmap": true,
  "num_thread_h": 0,
  "num_thread_k": 0,
  "num_thread_v": 0,
  "num_aarch64_microkernels": 0,
  "use_mlock": false,
  "use_mmap": true,
  "num_batch": 512,
  "num_ubatch": 512,
  "f16_kv": true,
  "logits_all": false,
  "embedding": false,
  "vocab_only": false,
  "lora_adapters": [],
  "lora_base": "",
  "lora_scale": 1.0,
  "rope_scaling_type": "",
  "rope_scaling_factor": 0.0,
  "rope_scaling_yarn_orig_ctx": 0,
  "rope_scaling_yarn_attn_factor": 0.0,
  "offload_kqv": true,
  "no_kv_offload": false,
  "flash_attn": false,
  "cache_type_k": "f16",
  "cache_type_v": "f16",
  "pp_num": 1,
  "pp_split": null,
  "split_mode": 1,
  "main_gpu": 0,
  "tensor_split": null,
  "num_gpu": -1,
  "ctx_size": 2048,
  "batch_size": 512,
  "n_predict": 256,
  "n_keep": 0,
  "n_ctx": 2048,
  "n_batch": 512,
  "n_threads": 0,
  "n_threads_batch": 0,
  "seed": -1,
  "num_gqa": 0,
  "num_rank": 1,
  "num_streams": -1,
  "rope_freq_base": 0.0,
  "rope_freq_scale": 0.0,
  "no_kv_offload": false,
  "offload_kqv": true,
  "flash_attn": false,
  "log_level": "info",
  "log_disable": false,
  "log_json": false,
  "mlock": false,
  "mmap": true,
  "num_thread_h": 0,
  "num_thread_k": 0,
  "num_thread_v": 0,
  "num_aarch64_microkernels": 0,
  "use_mlock": false,
  "use_mmap": true,
  "num_batch": 512,
  "num_ubatch": 512,
  "f16_kv": true,
  "logits_all": false,
  "embedding": false,
  "vocab_only": false,
  "lora_adapters": [],
  "lora_base": "",
  "lora_scale": 1.0,
  "rope_scaling_type": "",
  "rope_scaling_factor": 0.0,
  "rope_scaling_yarn_orig_ctx": 0,
  "rope_scaling_yarn_attn_factor": 0.0
}

Note: The above JSON is a representative structure. In practice, Ollama uses environment variables or a Modelfile for specific overrides. The critical parameters for low-memory CPU servers are OLLAMA_NUM_CTX and OLLAMA_NUM_GPU.

Practical Modelfile for 8 GB RAM

To run a model like phi3:mini on an 8 GB system, create a Modelfile:

DOCKERFILE
FROM phi3:mini
PARAMETER num_ctx 2048
PARAMETER num_gpu -1
PARAMETER num_thread 4
PARAMETER temperature 0.7
PARAMETER top_p 0.9
PARAMETER repeat_penalty 1.1

Then build and run:

BASH
ollama create phi3-optimized -f Modelfile
ollama run phi3-optimized "Explain quantum entanglement."

ShVaSa Intuition & Hardware Sizing

The viability of CPU inference on 8–16 GB RAM is not just about fitting the model; it is about the quality of the inference experience. Latency, token generation speed, and context retention are the key metrics.

8 GB RAM: The Survival Tier

16 GB RAM: The Sweet Spot

Memory Bandwidth and Latency

On CPU, memory bandwidth is the primary bottleneck. DDR4-3200 provides ~50 GB/s bandwidth, while DDR5-6000 provides ~100 GB/s. This directly impacts token generation speed. A CPU with DDR5 can generate tokens 2x faster than DDR4, all else being equal.

Comparison Table

RAMModel SizeQuantizationContext WindowEst. Latency (tokens/sec)Use Case
8 GB1.5B - 3.8BQ4_K_M2048 - 409610 - 25Simple QA, Code Assist
16 GB7B - 8BQ4_K_M4096 - 81925 - 15Complex Reasoning, Summarization

Grounding & Source Attribution

This analysis is grounded in the practical experience of deploying LLMs on resource-constrained hardware, drawing from community best practices and official documentation from Ollama and llama.cpp. The specific hardware constraints and model viability assessments are informed by the self-hosting community insights provided by AIHostBox in their publication on Medium, which details the realities of running local LLMs on non-GPU infrastructure.

The architectural decisions regarding quantization (Q4_K_M) and context window management are based on the GGUF specification and llama.cpp’s implementation details. The hardware sizing recommendations reflect the physical limits of DDR4/DDR5 memory bandwidth and CPU cache sizes for models in the 1.5B to 8B parameter range.

For further reading on the technical specifics of GGUF quantization and llama.cpp optimization, refer to the official llama.cpp GitHub repository and the Ollama documentation. The insights from AIHostBox provide the contextual framework for understanding the user experience and practical limitations of these setups in a self-hosted environment.

flowchart TD
    subgraph Client["1. Local LAN & Client Ingress"]
        A["Client Node / Local Browser"] --> B["Tailscale / WireGuard Tunnel"]
    end
    subgraph Gateway["2. Edge Routing & Invariant Validation"]
        B --> C["Caddy / Traefik Reverse Proxy"]
        C --> D{"Rate Limit & Token Auth Gate"}
    end
    subgraph Service["3. Sovereign Homelab Runtime"]
        D -->|Authorized| E["What actually runs well Service Container"]
        E --> F[("Encrypted Local ZFS Storage")]
    end
Author Avatar

Sharath Japa, ShVaSa Lab Lead

Systems & AI Infrastructure Researcher, DGX Station homelab lead. Engineering RL environments, edge silicon inference, and local reasoning model distillation. Verified Profiles: Google Scholar • Google Patents • LinkedIn • GitHub (@sharathjapa) • Medium • r/shvasa.


Canonical Source: https://shvasa.us/posts/what-actually-runs-well-with-ollama-on-a-cpu-server-with-816-gb-r

Advertisement

Related Research & Architectural Blueprints