AI Workflows

How to Run Private Local AI Models Using Ollama (Complete Setup & RAM Sizing Guide)

Running large language models (LLMs) directly on your own laptop, desktop, or Linux server eliminates recurring API bills and keeps sensitive notes, codebases, and client documents completely offline. Ollama packages model weights, quantization settings, and a local REST server into a single lightweight binary.

This guide walks through exact hardware sizing, clean installation on Windows and Linux, model selection by RAM capacity, and how to troubleshoot common performance bottlenecks.

Why Hardware Sizing Matters Before Pulling Models

Every open-weight model consumes memory based on two factors: parameter count (such as 3B, 7B, 8B, or 14B) and quantization precision (typically 4-bit Q4_K_M by default in Ollama). On top of the model weights, your system needs extra memory for the context window (KV cache) and the operating system itself.

If a model exceeds your GPU’s dedicated VRAM, Ollama automatically spills layers onto system RAM and CPU cores—which drops generation speed from 40+ tokens per second down to 2–5 tokens per second.

Available VRAM / System RAM Recommended Model Size Suggested Quantization Expected Experience
4 GB VRAM or 8 GB RAM 1B – 3B models Q4_K_M Fast replies, ideal for summaries & quick drafting
6 GB – 8 GB VRAM (or 16 GB RAM) 7B – 8B models Q4_K_M Balanced daily driver for coding, notes & reasoning
12 GB – 16 GB VRAM (or 32 GB RAM) 12B – 14B models Q4_K_M / Q5_K_M Strong structured output & multi-step instructions
24 GB+ VRAM (or 48 GB+ RAM) 27B – 32B models Q4_K_M High-accuracy coding, analysis & local agents

Step 1: Installing Ollama on Windows and Linux

Windows Installation

On Windows 10 or Windows 11, download the official installer from Ollama’s website or install via Windows Package Manager (winget) from PowerShell:

winget install Ollama.Ollama

Once installed, Ollama runs as a background tray service and exposes its local API on http://127.0.0.1:11434. Verify the CLI works:

ollama --version

Linux / Ubuntu Server Installation

On Ubuntu 22.04 or 24.04, run the official installation script, which sets up the ollama systemd service automatically:

curl -fsSL https://ollama.com/install.sh | sh
systemctl status ollama

If your Linux machine has an NVIDIA GPU, verify that nvidia-smi reports your driver before running models so Ollama uses CUDA acceleration instead of CPU-only mode.

Step 2: Pulling and Running Your First Models

Avoid downloading massive 70B models on an 8 GB or 16 GB machine. Start with compact, capable models matched to your hardware tier:

  • Lightweight (8 GB RAM laptops): ollama run llama3.2:3b
  • General daily use (16 GB RAM / 8 GB GPU): ollama run llama3.1:8b
  • Coding & structured JSON (16–32 GB RAM): ollama run qwen2.5-coder:7b or qwen2.5:14b

When you run ollama run, the weights download once and cache locally. Subsequent launches load straight from disk.

Checking Active Memory Usage

While a model is loaded in another terminal tab, inspect whether it fits on your GPU or spilled to CPU:

ollama ps

Look at the PROCESSOR column. Seeing 100% GPU means full hardware acceleration. Seeing 40% CPU / 60% GPU means the model is split across system RAM and VRAM.

Step 3: Customizing Context Length & System Prompts

By default, many Ollama models initialize with a smaller context window (such as 2,048 or 4,096 tokens) to conserve memory. When pasting long code files or meeting transcripts, increase the context window using a custom Modelfile:

FROM qwen2.5:7b
PARAMETER num_ctx 8192
PARAMETER temperature 0.3

Build and run your customized profile:

ollama create local-analyst -f Modelfile
ollama run local-analyst

Step 4: Securing the Local API Endpoint

By default, Ollama binds strictly to 127.0.0.1:11434 (localhost only), which is safe because external devices on your Wi-Fi or the public internet cannot reach it. If you expose Ollama to another device on your home LAN by setting OLLAMA_HOST=0.0.0.0, always pair it with:

  • A host firewall rule (ufw allow from 192.168.1.0/24 to any port 11434) so only your trusted subnet can connect.
  • Never expose port 11434 directly on a public cloud VPS without Nginx reverse-proxy authentication or a private WireGuard/Tailscale tunnel.

Common Problems and How to Fix Them

1. Responses Are Extremely Slow (1–3 Tokens/Sec)

Check ollama ps. If it shows 100% CPU on a system with an NVIDIA or AMD GPU, update your GPU drivers or ensure your model size does not exceed available VRAM. Switching from a 14B model to a 7B/8B Q4_K_M model usually restores full GPU speed.

2. Running Out of Disk Space on C: Drive or Root Partition

Model files range from 2 GB to 20+ GB each. Clean up unused models anytime with:

ollama list
ollama rm unused-model:tag

On Windows or Linux, you can relocate model storage to a secondary SSD by setting the OLLAMA_MODELS environment variable.

3. Model Forgets Earlier Parts of Long Documents

Increase num_ctx (for example to 8192 or 16384) in your Modelfile or API payload. Keep in mind that doubling context length increases KV-cache RAM consumption noticeably.

Summary Checklist

Start with a model sized comfortably under 75% of your available VRAM or system RAM, verify 100% GPU placement via ollama ps, keep port 11434 bound to localhost unless behind a firewall, and delete unused tags regularly to keep storage clean.

Leave a Reply

Your email address will not be published. Required fields are marked *