Running a model on your own computer
Tools like llama.cpp and Ollama let you run open-weight models on a laptop. Learn how much memory you need, when a GPU helps, and what a GGUF file is.
In 60 seconds
Running a model on your own computer
Tools like llama.cpp and Ollama let you run open-weight models on a laptop. Learn how much memory you need, when a GPU helps, and what a GGUF file is.
GGUF: the file format
Q4 or Q8. These roughly tell you how many bits each weight uses.How much memory do you need?
| Precision | Bytes per parameter | 1B-parameter model | 7B-parameter model |
|---|---|---|---|
| 16-bit | 2 | about 2 GB | about 14 GB |
| 8-bit | 1 | about 1 GB | about 7 GB |
| 4-bit | 0.5 | about 0.5 GB | about 3.5 GB |
def estimate_gb(params_billion: float, bits: int, overhead: float = 1.2) -> float:
"""Weights only, times a rough overhead factor for runtime and context."""
bytes_per_param = bits / 8
weights_gb = params_billion * bytes_per_param # 1B params x 1 byte = about 1 GB
return round(weights_gb * overhead, 1)
for size in (1, 3, 7):
for bits in (16, 8, 4):
print(f"{size}B model at {bits}-bit: about {estimate_gb(size, bits)} GB")CPU or GPU?
| Hardware | Good for | Watch out for |
|---|---|---|
| CPU only | Small models, learning, low traffic. Works on almost any laptop. | Slower generation, especially for bigger models |
| Laptop or desktop GPU | Much faster generation if the model fits in the GPU's own memory (VRAM) | If the model is bigger than VRAM, part of it runs on the CPU and speed drops |
| Apple silicon Mac | CPU and GPU share one memory pool, which llama.cpp can use | Shared memory is also used by everything else you run |
Getting started (examples: check the current docs)
# Ollama: download a model and chat with it in the terminal
ollama run <model-name>
ollama list # models you have downloaded
# llama.cpp: run a GGUF file you downloaded yourself
llama-cli -m ./my-model.gguf -p "Explain UPI in two sentences."
# llama.cpp: start a local server your own code can call
llama-server -m ./my-model.gguf --port 8080import requests
resp = requests.post(
"http://localhost:11434/api/generate",
json={"model": "<model-name>", "prompt": "Give three tips for saving water at home.", "stream": False},
timeout=120,
)
resp.raise_for_status()
print(resp.json()["response"])Watch and read more
Lab
A small model running on your own computer, or a written plan for running one.
The problem
Option A (if you can install software):
- Install Ollama or build llama.cpp by following its official instructions.
- Pick a small model whose licence you have read. Run it and ask it five questions: two in English, two in an Indian language you know, and one about a fact you can check.
- Record: model name and size, quantisation, time to first answer, whether each answer was correct, and your RAM use (from your system monitor).
Option B (on paper):
- Write down your computer's RAM, CPU and GPU (if any).
- Use the memory table or the Python estimate to choose a model size and quantisation that fits with room to spare.
- Write the steps you would follow, where you would download the model from, and five test questions with the answers you expect.
Practice lab
Edit the code and run it. Python runs in your browser — nothing is sent to our server.
No output. Add print(...) to see values.
You are done when
Hard questions
Try to answer before you reveal. If you can answer these, you understood the lesson.
Q1Two GGUF files of the same model are labelled Q8 and Q4. The Q4 one answers your questions just as well. Why might you still keep testing?Reveal
Five questions are too few to see small quality losses. The lower-bit file might fail more on harder questions, longer answers, or Indian languages, which you did not test much. Build a larger test set from real tasks, then compare the two on the same set before deciding.
Q2Why is "only use half your RAM for the model" a sensible rule on a laptop?Reveal
The operating system, browser and other apps also need memory, and the model's context cache grows during long conversations. If memory runs out, the computer starts swapping to disk and everything becomes very slow. Leaving room keeps both the model and your machine usable.
Questions people ask
I do not have a GPU. Can I still run a model?
Yes. llama.cpp and Ollama run on the CPU. Small models are usable for learning and light work. Generation will be slower than with a GPU, so start small.
Why is the first answer slow and later ones faster?
The first time, the runtime has to load the model file from disk into memory. After that it stays loaded for a while, so answers start sooner.
What is the difference between llama.cpp and Ollama?
llama.cpp is the lower-level engine with many options. Ollama wraps a similar engine in a simpler tool with a model library and a local API. Beginners often start with Ollama; people who want fine control often use llama.cpp directly.
My laptop gets very hot. Is that a problem?
Running a model uses the processor heavily, so heat is normal. Keep air vents clear, use a hard surface, and stop if the machine becomes unstable. Smaller models and shorter answers reduce the load.
Lesson test
5 questions. Get 3 right (60%) to pass and complete this lesson.