How to Run LLMs Locally With Ollama: Size the Model, Then Install

Install Ollama, whose current stable release is v0.40.16 (published 9 November 2026), then run ollama run gemma4:e2b, the example in Ollama’s quickstart. That model is a download of about 7.2 GB, and the quickstart recommends 8 GB of available VRAM or Mac unified memory, so the 11 steps below start by turning your own memory into a maximum model file size, using the quickstart’s ratio and the 20% operating-system reserve from AMD’s Ollama playbook. Commands and version facts were checked against Ollama’s documentation and release notes on 15 November 2026; the sizing rule is our calculation, not a test.

Google · Preferred Sources

Don't miss new tech stories on Google

Add Tech Insider once in the Google app and our stories appear in your news suggestions.

Add Now

Fit the model to your memory before you install anything

Step 1: convert your memory into the largest model file you can load

The quickstart pairs a 7.2 GB download with a recommendation of 8 GB, and adds that larger context windows need more memory. Dividing 8 by 7.2 gives a ratio of 1.11 GB of memory per GB of file. On a discrete GPU, the largest file is therefore VRAM divided by 1.11. On a machine where the GPU shares system RAM, AMD’s playbook says to leave roughly 20% of RAM for the operating system, which leaves 80% (0.8) usable, so the largest file is RAM times 0.8, divided by 1.11. The quickstart also says that with less VRAM Ollama can use system RAM but responses may be slower, so this rule marks the line for staying in fast memory.

Memory tierLargest model file
8 GB VRAM7.2 GB
12 GB VRAM10.8 GB
16 GB VRAM14.4 GB
24 GB VRAM21.6 GB
8 GB shared RAM or unified memory5.8 GB
16 GB shared RAM or unified memory11.5 GB
32 GB shared RAM or unified memory23.1 GB
64 GB shared RAM or unified memory46.1 GB

Find your memory tier in the table, then compare it with the file size on a model’s library page.

Two sourced model sizes show how to read it. gemma4:e2b (7.2 GB) sits exactly on the 8 GB VRAM line, so it fits any discrete card at 8 GB or above. On shared memory, 8 GB of RAM gives only 5.8 GB, so the 16 GB tier (11.5 GB) is the entry point. gpt-oss:20b, which AMD’s playbook sizes at about 12 GB, fits a 16 GB card (14.4 GB) but narrowly misses the 16 GB shared tier (11.5 GB): 12 × 1.11 ÷ 0.8 is 16.65, so it needs about 16.7 GB of RAM, which in practice means the 32 GB tier. AMD’s playbook recommends 32 GB of system memory for that model, so the rule and the playbook land on the same tier. The rule tells you the file fits, and the playbook figure probably leaves room for the longer context windows the quickstart warns about.

Northwestern’s local LLM guide gives the same advice: gemma3:4b for most laptops and desktops, gemma3:27b for high-end machines such as Macs with 64GB+ of RAM, and a warning that models can be large enough to fill a typical computer’s storage, so check the size in the Ollama library before pulling.

Move one tier up if you plan long context windows.

Read the tag before you pull: a lower-bit tag of the same model moves it down a tier.

For larger models the same arithmetic works backwards from parameters. The v0.40.16 release notes add Ripple Preview, a 65B dense model built for agentic coding (ollama run ripple-preview). If its default file is a 4-bit quantization, which is an assumption, 65 × 4 ÷ 8 gives 32.5 GB; 32.5 × 1.11 ÷ 0.8 is 45.1 GB of shared RAM, so it belongs in the 64 GB tier. Read the real file size on the model’s library page before you pull it. Ceilings also move between releases: the same notes say Qwen3.8 Flash Next uses about 27 GiB less memory on Apple silicon, so redo the sums after an upgrade.

Install Ollama and check that the server answers

Step 2: install the app or the script

The quickstart tells you to download Ollama for macOS, Windows or Linux, open the app or run ollama from a terminal, follow the setup prompts, and then either sign in to use cloud models or choose a local model. On Linux, AMD’s playbook installs with the official script and verifies with ollama --version. Fetching the script first lets you read it before it runs:

# Linux: download the installer, read it, then run it
curl -fsSL https://ollama.com/install.sh -o install.sh
less install.sh
sh install.sh
ollama --version

AMD’s own one-line form is curl -fsSL https://ollama.com/install.sh | sh, which runs the script unread. On Windows, download the installer from the quickstart, or run winget install Ollama.Ollama from a terminal as the earlier edition of this page did, then open a new terminal and run ollama --version.

The winget line is unverified against an official source, so check that the package ID resolves on your machine before relying on it.

Install the stable build. On the Ollama releases page, v0.40.16 (9 November 2026) is marked Latest, while v0.40.17, dated 10 November, is a pre-release carrying mlx concurrent generation and a llama.cpp version bump. v0.40.16 also added CUDA 13.5 support for Windows on ARM, and since v0.40.15 running ollama with no arguments opens the welcome launcher. If you would rather start from a graphical app, our LM Studio and Ollama comparison sets the two side by side.

Step 3: confirm the version and the server

ollama --version
curl http://localhost:11434          # replies: Ollama is running
curl http://localhost:11434/v1/models
curl http://localhost:11434/api/tags # native route: installed models, as in the earlier edition

The version should report 0.40.16; any notes that expect 0.13.x output are out of date. Per Ollama’s API introduction, the local native API lives at http://localhost:11434/api and the OpenAI-compatible one at http://localhost:11434/v1, so the second command asks the server for its model list. The earlier edition of this page also used a bare curl http://localhost:11434, which answered “Ollama is running” when the server was up. Per the v0.40.16 release notes, /v1/models returns an empty list rather than null when no models are installed. If the connection is refused on Linux, the quickstart says to start the server with ollama serve when it is not already running.

Pull a first model, then manage what is on disk

Step 4: pull and chat

ollama pull gemma4:e2b
ollama run gemma4:e2b
# type /bye to leave the chat

Per the quickstart, ollama run downloads the model and starts a chat on your computer, and /bye ends it. Northwestern’s guide notes the first load of a model can take a while, especially for larger ones, and that an “out of memory” error means you should try a smaller model: go back to the table in Step 1 and move down a row.

Step 5: read model names and keep the disk under control

AMD’s playbook explains that model names follow name:tag, where the tag usually indicates the parameter count or quantization variant. Two tags of one family can therefore differ a lot in file size, and the file size is what Step 1 compares against your memory. The playbook lists four management commands:

ollama list              # show downloaded models
ollama pull gpt-oss:20b  # download without running (about 12 GB)
ollama show gpt-oss:20b  # metadata and parameters
ollama rm gpt-oss:20b    # delete the model to free disk space

AMD says the roughly 12 GB gpt-oss:20b download happens once and later runs load from disk, which is why a full drive is the first thing to check when pulls start failing.

The earlier edition of this page also showed how to build a custom model from a Modelfile with ollama create. Ollama’s Modelfile reference is not among the sources this edition was checked against, so treat this minimal example as unverified and confirm the syntax in that reference before relying on it:

# Minimal custom model built on a model you already pulled
printf 'FROM gemma4:e2b\n' > Modelfile
ollama create my-gemma -f Modelfile
ollama run my-gemma
# ollama rm my-gemma removes it again

Step 6: try the newer models against your tier

Two recent additions are worth sizing before you pull them. The v0.40.15 notes added Xiaomi’s mimo-v2.6, a 9B model built for code and agent workflows (ollama run mimo-v2.6). Ripple Preview, covered in Step 1, is the 65B option. Parameter count alone does not give the file size, so read each model’s library page, then compare it with your row in the table. For a worked run of one large model, see our guide to running Qwen3.8-27B locally with Ollama. Readers who want to run models without Ollama can follow our llama.cpp tutorial.

Call the server from code and check what changed in 0.40.14 to 0.40.16

Step 7: pick the native API or the /v1 route

RouteLocal serverOllama cloud
Native APIhttp://localhost:11434/apihttps://ollama.com/api
OpenAI-compatiblehttp://localhost:11434/v1https://ollama.com/v1

Pick /api for Ollama’s own request format and /v1 when existing code already speaks the OpenAI format. The API introduction says the API is not strictly versioned but is expected to be stable and backwards compatible, and that deprecations are rare and announced in the release notes. It also says the official Python and JavaScript libraries work with either a local server or the hosted API. The JavaScript library added web search and web crawl, plus loading OLLAMA_API_KEY from the environment, in ollama-js v0.6.0, and thinking support in v0.5.16 with thinking levels in v0.5.17.

# Native chat endpoint, one JSON reply
curl http://localhost:11434/api/chat -d '{
  "model": "gemma4:e2b",
  "messages": [{"role": "user", "content": "Say hello."}],
  "stream": false
}'
# pip install ollama
import ollama

try:
    reply = ollama.chat(
        model="gemma4:e2b",
        messages=[{"role": "user", "content": "Say hello."}],
    )
    print(reply["message"]["content"])
except Exception as err:
    raise SystemExit(f"Ollama call failed: {err}")

To print the reply as it arrives instead of waiting for the whole answer, pass stream=True and loop over the chunks:

# Streaming: print each chunk as it arrives
import ollama

stream = ollama.chat(
    model="gemma4:e2b",
    messages=[{"role": "user", "content": "Say hello."}],
    stream=True,
)
for chunk in stream:
    print(chunk["message"]["content"], end="", flush=True)

To keep a conversation going between runs, this script saves the message list to a JSON file and reloads it next time. It calls the server locally via the same Python library, so nothing leaves your machine:

# Chat that remembers earlier turns between runs
# usage: python chat.py "your question"
import json
import sys
from pathlib import Path

import ollama

HISTORY_FILE = Path("chat_history.json")


def load_history():
    if HISTORY_FILE.exists():
        with open(HISTORY_FILE) as f:
            return json.load(f)
    return []


def save_history(messages):
    with open(HISTORY_FILE, "w") as f:
        json.dump(messages, f)


messages = load_history()
messages.append({"role": "user", "content": " ".join(sys.argv[1:]) or "Say hello."})
response = ollama.chat(model="gemma4:e2b", messages=messages)
messages.append({"role": "assistant", "content": response["message"]["content"]})
save_history(messages)
print(response["message"]["content"])

For an interactive terminal session instead, this script lists the installed models, checks that the one you name is among them, streams each reply, lets you switch models with /model NAME, and sends only the most recent messages back to the model. Ctrl+C or /bye ends it. The script reads each model name from the entries in ollama.list(), using the name key where an entry has one and the model key otherwise:

# Interactive chat: list models, stream replies, switch models, keep a trimmed history
# usage: python interactive_chat.py [model]
import sys

import ollama

MAX_MESSAGES = 20


def get_available_models():
    try:
        return [m['name'] if 'name' in m else m['model'] for m in ollama.list()['models']]
    except Exception:
        return []


def chat(model: str, messages: list) -> list:
    trimmed = messages[-MAX_MESSAGES:]
    full_response = ""
    for chunk in ollama.chat(model=model, messages=trimmed, stream=True):
        token = chunk["message"]["content"]
        print(token, end="", flush=True)
        full_response += token
    print()
    messages.append({"role": "assistant", "content": full_response})
    return messages


def main():
    available = get_available_models()
    model = sys.argv[1] if len(sys.argv) > 1 else "gemma4:e2b"
    if available:
        print("Installed models:", ", ".join(available))
    if not available or model not in available:
        raise SystemExit(f"{model} is not installed. Installed: {available}. Run: ollama pull {model}")
    messages = []
    print("Type /model NAME to switch models, /bye to quit.")
    while True:
        try:
            user_input = input("you> ").strip()
        except (KeyboardInterrupt, EOFError):
            print()
            break
        if not user_input:
            continue
        if user_input.lower() in ("/bye", "/quit"):
            break
        if user_input.startswith('/model '):
            new_model = user_input.split(None, 1)[1]
            if new_model in available:
                model = new_model
                messages = []
                print(f"Switched to {model}")
            else:
                print(f"{new_model} is not installed. Run: ollama pull {new_model}")
            continue
        messages.append({"role": "user", "content": user_input})
        messages = chat(model, messages)


if __name__ == "__main__":
    main()

For searching your own documents, Northwestern’s guide uses the Nomic Embed model. The Python library can request an embedding from the local server once an embedding model is pulled; confirm the exact tag on that model’s library page before running this:

# Turn a piece of text into an embedding vector with a local embedding model
import ollama

embedding = ollama.embed(model="nomic-embed-text", input="Say hello.")["embeddings"][0]
print(len(embedding))
# pip install openai  (the /v1 route; local requests need no real key)
from openai import OpenAI

client = OpenAI(base_url="http://localhost:11434/v1", api_key="unused")
reply = client.chat.completions.create(
    model="gemma4:e2b",
    messages=[{"role": "user", "content": "Say hello."}],
)
print(reply.choices[0].message.content)

# List the installed models through /v1/models
models = client.models.list()
for model in models:
    print(model.id)

Step 8: check your scripts against the release-note changes

Three point releases changed how clients behave. The table lists each change from the release notes with the thing to check in a script written for an older build.

ReleaseChange in the notesCheck in your script
v0.40.14OpenAI-compatible endpoints no longer override a model’s packaged sampler defaults; a client that sends no temperature or top_p gets the model’s own values instead of 1.0, matching /api/chat.If answers through /v1 changed after upgrading, send temperature and top_p explicitly to pin them.
v0.40.15Recurrent and vision GGUF models can serve more than one request at a time. Running ollama with no arguments opens the welcome launcher.Overlapping requests to those models are now served together. Call ollama run <model> in scripts, never bare ollama.
v0.40.16/v1/responses respects truncation and no longer silently truncates by default.Re-send your longest prompts through /v1/responses and confirm the output.
v0.40.16/v1/models returns an empty list instead of null when no models are installed.Test for an empty list, not for null.
v0.40.16ollama launch claude always routes Claude Code to the selected model.Re-select the model if you launch agents from scripts (see Step 10).

Run it in Docker, with or without a GPU

Step 9: start the container with the port bound to localhost

Ollama’s Docker Hub entry (last updated 10 November 2026) gives a CPU-only command that exposes port 11434. For NVIDIA GPUs, install the NVIDIA Container Toolkit and add --gpus=all; for AMD GPUs use the rocm tag. The commands below bind the port to 127.0.0.1 instead of every interface, because local requests need no API key and anyone who can reach an open port can use the server.

# CPU-only, reachable from this machine only
docker run -d -v ollama:/root/.ollama -p 127.0.0.1:11434:11434 --name ollama ollama/ollama

# NVIDIA GPU instead (needs the NVIDIA Container Toolkit)
# docker run -d --gpus=all -v ollama:/root/.ollama -p 127.0.0.1:11434:11434 --name ollama ollama/ollama

# Run a model inside the container
docker exec -it ollama ollama run gemma4:e2b

# Remove the container; the named volume "ollama" keeps downloaded models
docker rm -f ollama
# Deletes every downloaded model too, run only when you mean it:
# docker volume rm ollama

Run only one of the two docker run lines, and use docker rm -f ollama before switching between them, since both claim the container name.

The earlier edition also used Docker Compose. This file describes the same CPU-only container with the same localhost binding and named volume; it is our translation of the Docker Hub command, not a file from Ollama’s documentation. Start it with docker compose up -d and stop it with docker compose down:

# compose.yaml: same container as the docker run line above
services:
  ollama:
    image: ollama/ollama
    container_name: ollama
    ports:
      - "127.0.0.1:11434:11434"
    volumes:
      - ollama:/root/.ollama

volumes:
  ollama:

Add a coding agent or your own documents

Step 10: use ollama launch, AnythingLLM, or cloud models

The quickstart shows launching a coding agent from your project directory, with Claude Code, Codex CLI and OpenCode listed. ollama launch claude offers to install Claude Code if needed, and since v0.40.16 it always routes Claude Code to the selected model.

For questions over your own files, Northwestern’s guide pairs Ollama with the AnythingLLM desktop app, which gives chat threads and search, and optionally the Nomic Embed model for local retrieval. For larger documents it recommends a chunk size of 2000 with an overlap of 200.

Staying local is a choice, not a default of the app: the quickstart offers sign-in for cloud models, and cloud requests to ollama.com need an API key, while requests to localhost do not.

The earlier edition of this page also had two shell helpers that pipe text from your own tools into a local model. These are minimal versions with the model switched to gemma4:e2b. They are not from Ollama’s documentation, so try them on a throwaway repository and a test pod first. Both send text only to the model on your machine:

# Suggest a commit message for the staged changes, then ask before committing
suggest_commit() {
  local diff=$(git diff --staged)
  if [ -z "$diff" ]; then
    echo "No staged changes"
    return 1
  fi
  local msg=$(echo "$diff" | ollama run gemma4:e2b "Write a one-line commit message for this diff. Reply with the message only.")
  echo "Suggested: $msg"
  read -p "Commit with this message? [y/n] " choice
  case $choice in
    y|Y) git commit -m "$msg" ;;
    *) echo "Not committed" ;;
  esac
}

# Summarise the errors in the last 100 lines of a pod's logs
analyze_logs() {
  if [ -z "$1" ]; then
    echo "Usage: analyze_logs POD_NAME"
    return 1
  fi
  kubectl logs "$1" --tail=100 | ollama run gemma4:e2b "Summarise the errors in these logs and the likely cause."
}

Three symptoms and the step that fixes each

SymptomLikely causeFix
Out-of-memory error on loadThe model file is above your tier’s ceiling. Northwestern’s advice is to try a smaller model.Pick a smaller tag or model from Step 1, and a shorter context, since larger windows need more memory.
Replies arrive slowlyWith less VRAM than the model needs, Ollama can use system RAM, and responses may be slower (quickstart).Choose a file under the VRAM ceiling in the table.
Connection refused on localhost:11434 (Linux)The server is not running.Run ollama serve, then repeat Step 3.

After every upgrade, re-run four checks

Step 11: version, server, behaviour table

  1. Version. ollama --version reports the build you meant to run. The stable build on 15 November 2026 is v0.40.16.
  2. Server. curl http://localhost:11434/v1/models answers, or on Linux ollama serve brings the server up.
  3. Empty model list. Your scripts test for an empty list from /v1/models, not for null.
  4. Sampler defaults. Send temperature and top_p explicitly if answers through /v1 changed; see the Step 8 table.

Stay on v0.40.16 for anything you depend on; v0.40.17 (10 November 2026) is a pre-release, so read its notes before taking it.

Sofia Lindström

Sofia Lindström

Security and privacy

Sofia Lindström writes about security and privacy for Tech Insider: software vulnerabilities and the updates that fix them, data breaches, privacy rules and how products handle personal data. She works from vendor advisories, official vulnerability catalogues and the documents behind each story.

View all articles