How to run an LLM locally with Ollama (even on 8GB RAM)
Run an LLM locally with Ollama: install it, pick a model that fits your RAM, call it with curl, make embeddings with nomic-embed-text and use it in n8n.
By Md Anjum Kamali · · 5 min read

On this page
To run an LLM locally with Ollama, install it with one command, pull a model with ollama pull, and chat with it using ollama run. Ollama also starts a local API on port 11434, so your scripts and tools like n8n can call the model over HTTP. On a machine with 8GB of RAM, stick to models around 3B parameters and you'll be fine.
I run Ollama on a used mini PC under my desk with an i5 and 8GB of RAM. It serves Qwen 2.5 3B for small text jobs and nomic-embed-text for embeddings. Here's how to set up the same thing.
Ollama is a free tool that downloads open-weight language models and runs them on your own computer, with a command line for chatting and a local HTTP API for code.
How do you install Ollama?
On Linux, the official install docs use a single script:
curl -fsSL https://ollama.com/install.sh | sh
On a normal Ubuntu install this also registers Ollama as a systemd service, so it starts at boot. Check it's running:
systemctl status ollama
On macOS and Windows, download the app from ollama.com and run the installer. The commands below work the same everywhere.
To update later, run the install script again.
How do you download and run a model?
ollama pull qwen2.5:3b # download the model
ollama run qwen2.5:3b # chat with it in the terminal
Type a message and press Enter. Type /bye to leave. A few other commands you'll use:
ollama list # models you've downloaded
ollama ps # models loaded in memory right now
ollama rm qwen2.5:3b # delete a model
The qwen2.5 family comes in 0.5b, 1.5b, 3b, 7b, 14b, 32b and 72b sizes. The number is billions of parameters, and it's the main thing that decides how much memory a model needs.
How much RAM do you need to run a local LLM?
The download size is a decent first guide, because the model has to fit in memory with room to spare. Ollama's library page lists the default qwen2.5:3b as a 1.9GB download in Q4_K_M quantization. The nomic-embed-text model is 274MB.
Earlier versions of Ollama's README gave a rule of thumb of at least 8GB of RAM to run 7B models. In my experience on an 8GB box that also runs Docker, n8n and Postgres, 3B is the comfortable size.
| Your RAM | What to try | Good for |
|---|---|---|
| 8GB | 1.5B to 3B models, plus an embedding model | Classifying, extracting fields, short summaries, embeddings |
| 16GB | 7B to 8B models | General chat, drafting, simple coding help |
| 32GB or more | 14B and up | Longer reasoning, better writing quality |
Two more things eat memory. Ollama keeps a model loaded for 5 minutes after the last request, according to the Ollama FAQ, so two models used close together can both sit in RAM. And the context window takes memory too. The default is 4096 tokens, and you can raise it with OLLAMA_CONTEXT_LENGTH, but on a small machine raising it is a fast way to run out.
A GPU makes everything faster, but you don't need one. My mini PC has no graphics card, and a 3B model on the CPU is fine for jobs that don't need an instant reply.
How do you call Ollama from code?
Ollama listens on http://localhost:11434. Here are the three endpoints I use.
Generate a single reply
curl http://localhost:11434/api/generate -d '{
"model": "qwen2.5:3b",
"prompt": "Classify this reply as interested, not_interested or out_of_office: Thanks, send me pricing.",
"stream": false
}'
Without "stream": false you get the answer back token by token as separate JSON lines. The text is in the response field.
Chat with message history
curl http://localhost:11434/api/chat -d '{
"model": "qwen2.5:3b",
"messages": [
{ "role": "system", "content": "You extract company names. Reply with the name only." },
{ "role": "user", "content": "Hey, I run growth at Acme Analytics, saw your post." }
],
"stream": false
}'
The reply is in message.content.
Make embeddings with nomic-embed-text
Embeddings turn text into a list of numbers so you can search by meaning. Pull the model first:
ollama pull nomic-embed-text
Then:
curl http://localhost:11434/api/embed -d '{
"model": "nomic-embed-text",
"input": ["How do I reset my password?", "Pricing for the team plan"]
}'
The response has an embeddings array with one vector per input. Before you create a vector column in Postgres with pgvector, check the vector length so the column size matches:
curl -s http://localhost:11434/api/embed \
-d '{"model":"nomic-embed-text","input":"test"}' | jq '.embeddings[0] | length'
This is how my memory project works: text goes through nomic-embed-text, the vectors go into Postgres with pgvector, and an MCP server lets AI assistants search them. Everything stays on the mini PC.
You'll see older examples online using /api/embeddings with a prompt field. That's the older endpoint. /api/embed takes one string or a list.
How do you use Ollama from n8n?
This is where a local model gets useful, because n8n can call it in the middle of a workflow for free. Ollama's own n8n integration page covers the basics. The catch is networking when n8n runs in Docker.
-
Make Ollama listen on all interfaces, not just localhost. Run
sudo systemctl edit ollama.serviceand add:[Service] Environment="OLLAMA_HOST=0.0.0.0:11434"Then
sudo systemctl daemon-reloadandsudo systemctl restart ollama. -
Let the n8n container find the host. On Linux without Docker Desktop, add this to the n8n service in your
docker-compose.yml:extra_hosts: - "host.docker.internal:host-gateway" -
In n8n, create an Ollama credential with the base URL
http://host.docker.internal:11434. It should say the connection tested successfully. -
Use the Ollama Chat Model node under an AI Agent or Basic LLM Chain for text, and the Embeddings Ollama node when you need vectors for a vector store.
Ollama's API has no login. Opening it to 0.0.0.0 is fine on a home network behind a router, but never forward port 11434 to the internet or put it on a public tunnel hostname.
If you haven't set up n8n yet, I wrote up how to self-host n8n with Docker, and the hardware is in my mini PC home server post.
What are small local models good at?
Be realistic about a 3B model. It's good at narrow jobs with a clear instruction: pull a company name out of an email, tag a support ticket, turn a messy job title into a seniority level, or write a one-line summary. It's weak at long reasoning, and it calls tools unreliably inside an agent.
So I use the local model for high-volume, low-stakes steps where sending every item to a paid API would add up, and a hosted model for anything that needs real thinking. That split keeps costs near zero for the boring work.
Start with qwen2.5:3b and nomic-embed-text, wire one of them into a single n8n workflow, and see if the quality is good enough for that one job. If it is, you've got a free model running 24 hours a day under your desk.
Questions people ask
Can I run Ollama on 8GB of RAM?
Yes, with small models. I run Qwen 2.5 3B and nomic-embed-text on a mini PC with 8GB of RAM next to n8n and Postgres. The 3B Qwen download is 1.9GB, which leaves room for everything else. 7B models are about the ceiling for 8GB, and only if little else is running.
Does Ollama need a GPU?
No. Ollama runs on the CPU when there's no supported GPU. It's slower, but small models are usable for short jobs like tagging text or making embeddings.
What port does Ollama use?
11434. By default Ollama only listens on 127.0.0.1:11434, so other machines and Docker containers can't reach it until you set OLLAMA_HOST to 0.0.0.0:11434.
Is Ollama free?
Yes. Ollama and the open models in its library are free to download and run on your own machine. Your only cost is the hardware and electricity.