
Last Update: January 23, 2025 7 min read
BY
eric
How to Install Ollama on Ubuntu or Debian and Run Your First Local LLM
Ollama downloads open-weight language models and runs them on your own machine, with a chat prompt in the terminal and an HTTP API on port 11434. On Ubuntu or Debian the whole setup is one install command and one run command:
curl -fsSL https://ollama.com/install.sh | sh
ollama run llama3.2
That's what I did on my Linux machine in January 2025, and the output from both is below. The rest of this post covers what the installer actually sets up, how to check the model is running on your GPU rather than your CPU, which model to start with, and the settings and fixes you'll need once you use it for more than a quick test.
What you need
- Ubuntu or Debian, 64-bit (x86_64 or ARM64), with
curlandsudo. A minimal Debian install may needsudo apt install curlfirst. - Memory. A small 1B to 3B model runs in a few GB. As a rough floor, have 8 GB of RAM for 7B to 8B models. My AI rig memory guide has a fuller sizing table.
- A GPU is optional but makes a big difference. Without one, Ollama runs on the CPU, which works but is slow for anything beyond small models.
- NVIDIA: install the proprietary driver before Ollama, and check that
nvidia-smiworks. You don't need the CUDA toolkit; Ollama ships its own CUDA libraries. - AMD: recent Radeon cards are supported through ROCm. The installer downloads an extra ROCm bundle when it detects an AMD GPU.
- NVIDIA: install the proprietary driver before Ollama, and check that
- Disk space. Models are big: from about 1 GB for the smallest to 40 GB+ for 70B models.
Step 1: install Ollama
Piping a script from the internet into sh is convenient, but you can read it first if you prefer:
curl -fsSL https://ollama.com/install.sh -o ollama-install.sh
less ollama-install.sh
sh ollama-install.sh
Either way, this is what the installer printed on my machine:
>>> Installing ollama to /usr/local
>>> Downloading Linux amd64 bundle
######################################################################## 100.0%
>>> Creating ollama user...
>>> Adding ollama user to render group...
>>> Adding ollama user to video group...
>>> Adding current user to ollama group...
>>> Creating ollama systemd service...
>>> Enabling and starting ollama service...
Created symlink /etc/systemd/system/default.target.wants/ollama.service → /etc/systemd/system/ollama.service.
>>> NVIDIA GPU installed.
What that did:
- Put the
ollamabinary in/usr/local/binand its libraries under/usr/local/lib/ollama. - Created a system user called
ollama, and added it to therenderandvideogroups so it can use the GPU. - Created, enabled and started a systemd service,
ollama.service. The server starts on every boot and listens on127.0.0.1:11434. - The last line, "NVIDIA GPU installed.", means it found my NVIDIA card and driver. If you see a warning that no NVIDIA or AMD GPU was detected and Ollama will run in CPU-only mode, fix the driver first (see troubleshooting below) and re-run the installer.
Check the service:
systemctl status ollama
ollama --version
Step 2: run your first model
ollama run llama3.2
The first run downloads the model. For Llama 3.2 (3B) that was about 2.0 GB. Here's my run, with the progress bars shortened:
pulling manifest
pulling dde5aa3fc5ff... 100% ▕████████████████▏ 2.0 GB
pulling 966de95ca8a6... 100% ▕████████████████▏ 1.4 KB
pulling fcc5a6bec9da... 100% ▕████████████████▏ 7.7 KB
pulling a70ff7e570d9... 100% ▕████████████████▏ 6.0 KB
pulling 56bb8bd477a5... 100% ▕████████████████▏ 96 B
pulling 34bb5ab01051... 100% ▕████████████████▏ 561 B
verifying sha256 digest
writing manifest
success
>>> how are you
I'm just a language model, so I don't have feelings or emotions like humans do. However, I'm functioning properly and ready to assist you with any questions or tasks you may have! How
about you? How's your day going?
The big layer is the model weights; the small ones are the licence, the prompt template and default parameters. After the first run, ollama run llama3.2 starts straight away from the local copy.
Inside the chat prompt:
/?lists the commands./bye(or Ctrl+D) exits./set parameter num_ctx 8192raises the context window for this session."""starts and ends a multi-line message.
Step 3: check it's using your GPU
While a model is loaded (it stays in memory for about five minutes after your last message by default), run:
ollama ps
The PROCESSOR column tells you where the model is:
100% GPU: the whole model is in VRAM. This is what you want.- A split such as
40%/60% CPU/GPU: the model didn't fit in VRAM, so part of it runs on the CPU. It works, but much more slowly. Use a smaller model, a smaller quantisation, or a shorter context. 100% CPU: the GPU isn't being used at all. See troubleshooting.
On NVIDIA, nvidia-smi should also show an ollama process using VRAM while the model is loaded.
Which model to start with
Browse the Ollama library. Each model has tags for different sizes, such as llama3.2:1b or gemma2:27b; the tag without a suffix is the default size, usually a 4-bit quantisation.
These are some of the models Ollama's README listed when I wrote the first version of this post in January 2025, with their download sizes at the time:
A few things worth knowing when you pick:
- Match the download size to your VRAM. The model file plus a bit of room for the context should fit in your GPU memory if you want
100% GPU. On a 12 GB card, 7B to 8B models are comfortable and 14B models are about the limit; my RTX 3060 benchmark has real numbers. - The small
deepseek-r1tags are not the full DeepSeek-R1.deepseek-r1:1.5bup to:70bare smaller models distilled from it. The full model is 671B parameters and needs hundreds of GB of memory. - Vision models read images; they don't generate them.
llama3.2-visioncan describe a photo you give it. For generating images I use Stable Diffusion; see my Stable Diffusion WebUI Docker guide. - The list moves fast. Since January 2025 newer families such as Gemma 3, Qwen 3 and gpt-oss have arrived in the library and generally do better than the older models above at the same size. Check the library before you download 40 GB of something.
Two days after this post I tested deepseek-r1:32b with Ollama on maths, coding and reasoning questions. The 70B version didn't fit in that machine's 48 GB of memory.
Everyday commands
Use it from code: the API
The service is an HTTP API on http://localhost:11434. A one-off request with curl:
curl http://localhost:11434/api/generate -d '{
"model": "llama3.2",
"prompt": "Explain what a systemd service is in one sentence.",
"stream": false
}'
There's also /api/chat for multi-turn conversations, and an OpenAI-compatible endpoint at http://localhost:11434/v1, so most tools built for the OpenAI API work if you point their base URL there and give them any non-empty API key.
If you'd rather have a ChatGPT-style window than a terminal, I tested a lot of front ends that sit on top of Ollama: see the best free open-source chat UIs for LLMs (Open WebUI was the smoothest with Ollama) and Cherry Studio vs Chatbox for desktop apps. To answer questions from your own documents, see building a RAG system with open-source tools.
Changing settings: the systemd override
Because Ollama runs as a systemd service, you configure it with environment variables in a service override, not in your shell's .bashrc:
sudo systemctl edit ollama.service
Add the settings you need under [Service], for example:
[Service]
Environment="OLLAMA_MODELS=/data/ollama/models"
Environment="OLLAMA_CONTEXT_LENGTH=8192"
Then reload and restart:
sudo systemctl daemon-reload
sudo systemctl restart ollama
Settings people most often change:
OLLAMA_MODELS: where models are stored. By default the service keeps them under/usr/share/ollama/.ollama/models, which is on your root partition. If that's small, point this at a bigger disk. The folder must be owned by theollamauser:sudo mkdir -p /data/ollama/models && sudo chown -R ollama:ollama /data/ollama.OLLAMA_CONTEXT_LENGTH: default context window. The default is short to save memory. Long documents or chats get silently cut off at the start unless you raise it. A bigger context uses more VRAM, so checkollama psafterwards.OLLAMA_KEEP_ALIVE: how long a model stays loaded after the last request (for example30m, or-1to keep it loaded).OLLAMA_HOST: which address it listens on. Only change this if other machines need to reach it.
On network access: the Ollama API has no login. If you set OLLAMA_HOST=0.0.0.0:11434, anyone who can reach that port can use your GPU and download or delete your models. Keep it on your LAN behind a firewall, or use a VPN. Never forward port 11434 from your router. My Cherry Studio vs Chatbox post walks through connecting a client on another machine.
Troubleshooting
ollama ps shows 100% CPU on an NVIDIA machine. Run nvidia-smi. If it fails, the driver isn't installed or loaded: on Ubuntu, sudo ubuntu-drivers install then reboot. If the driver was installed after Ollama, re-run the install script so it detects the GPU. Then check journalctl -u ollama for GPU discovery errors.
It was using the GPU, then fell back to CPU after a suspend or resume. This is a known NVIDIA driver quirk on Linux. Restarting the service usually fixes it (sudo systemctl restart ollama); if not, reload the nvidia_uvm kernel module or reboot.
Responses are very slow. Check ollama ps. A CPU/GPU split means the model or its context doesn't fit in VRAM. Try a smaller size tag or reduce the context.
Error: could not connect to ollama app, is it running? The service isn't running. sudo systemctl start ollama, then journalctl -u ollama -e to see why it stopped.
Disk filling up. ollama list shows what you've downloaded; ollama rm the ones you don't use, or move storage with OLLAMA_MODELS.
Updating and uninstalling
To update, run the same install command again. It replaces the binary and keeps your models.
To uninstall completely:
sudo systemctl stop ollama
sudo systemctl disable ollama
sudo rm /etc/systemd/system/ollama.service
sudo rm -r /etc/systemd/system/ollama.service.d # only if you created an override
sudo rm $(which ollama)
sudo rm -r /usr/local/lib/ollama
sudo rm -r /usr/share/ollama # deletes downloaded models
sudo userdel ollama
sudo groupdel ollama
If you moved storage with OLLAMA_MODELS, delete that folder too.
Is running locally worth it?
The main reasons are privacy and control: your prompts and documents never leave the machine, there's no per-token bill, and it works offline once the model is downloaded. The trade-off is quality and speed. A model that fits on a consumer GPU won't match the best cloud models on hard tasks, and it's often slower than a cloud API, not faster. Local models are a good fit for private documents, high-volume simple jobs, and experimenting; for the hardest problems, cloud models are still ahead.
Previous Article
Next Article
Jan 17, 2025









Comments (0)
Leave a Comment