RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Eruo Fredoline
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /How-to
  5. /How to run quantized models on systems with limited RAM
HOW-TO · INF

How to run quantized models on systems with limited RAM

intermediate·15 min·By Eruo Fredoline
Target environment
Ubuntu 24.04 · Ollama 0.4.x
PREREQUISITES

System with 8-16 GB RAM, Ollama installed

What this does

Configures a low-memory Ollama environment by selecting small parameter-count models, applying Q4 quantization, and reducing the context window to keep RAM usage within system limits. The result is a working inference setup that avoids out-of-memory failures on 8-16 GB systems.

Steps

  1. Select a model with 1B-3B parameters in a Q4 variant. Small parameter counts have the lowest memory floor. Examples include Phi-3 and Gemma-2B.

    ollama pull phi3:q4_K_M
    

    Expected output: Progress bars and success.

  2. Reduce the context window to lower peak memory usage. Sets num_ctx to a smaller value, typically 1024-2048 tokens.

    OLLAMA_NUM_CTX=1024 ollama run phi3:q4_K_M "Hello, how are you?"
    

    Expected output: A generated response with lower peak RAM consumption.

  3. Monitor RAM during inference. Confirms memory stays within limits while the model generates.

    free -h
    

    Expected output: Available memory remains positive even during peak generation.

  4. Persist the context limit in the environment. Makes the setting apply to all subsequent Ollama calls.

    export OLLAMA_NUM_CTX=1024
    

    Expected output: No output; variable is set silently.

Verification

OLLAMA_NUM_CTX=1024 ollama run phi3:q4_K_M "Write one sentence." && free -h | awk 'NR==2{print "Free RAM: " $7}'
# Expected: generated output followed by free memory greater than 1 GB

Common failures

  • OOM kill during first prompt - Context window still too high; lower OLLAMA_NUM_CTX incrementally until successful.
  • response quality degradation - Context window too small truncates history; increase to 2048 if RAM permits.
  • model fails to generate - Q4 variant may be missing for this model; try a different base model or quantization level.
  • environment variable not persisting - Export command must run in the same shell as subsequent Ollama commands.

Related guides

  • How to choose the right quantization level based on your hardware
  • How to benchmark model response time using the Ollama API
RELATED GUIDES
INF
How to benchmark model response time using the Ollama API
INF
How to choose the right quantization level based on your hardware
← All how-to guidesCourses →