preloader
post-thumb

Last Update: January 23, 2025 7 min read


BYauthor-thumberic

|Loading...

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:

bash
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 curl and sudo. A minimal Debian install may need sudo apt install curl first.
  • 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-smi works. 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.
  • 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:

bash
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:

bash
>>> 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 ollama binary in /usr/local/bin and its libraries under /usr/local/lib/ollama.
  • Created a system user called ollama, and added it to the render and video groups so it can use the GPU.
  • Created, enabled and started a systemd service, ollama.service. The server starts on every boot and listens on 127.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:

bash
systemctl status ollama
ollama --version

Step 2: run your first model

bash
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:

bash
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 8192 raises 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:

bash
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:

Model
Parameters
Download size
Command
Llama 3.2
1B
1.3 GB
ollama run llama3.2:1b
Llama 3.2
3B
2.0 GB
ollama run llama3.2
Llama 3.1
8B
4.7 GB
ollama run llama3.1
Gemma 2
9B
5.5 GB
ollama run gemma2
Mistral
7B
4.1 GB
ollama run mistral
Phi 4
14B
9.1 GB
ollama run phi4
DeepSeek-R1 (distilled)
1.5B
1.3 GB
ollama run deepseek-r1:1.5b
Llama 3.2 Vision
11B
7.9 GB
ollama run llama3.2-vision
Llama 3.3
70B
43 GB
ollama run llama3.3

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-r1 tags are not the full DeepSeek-R1. deepseek-r1:1.5b up to :70b are 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-vision can 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

Command
What it does
ollama pull llama3.1
Download a model without starting a chat
ollama list
Show downloaded models and their sizes
ollama ps
Show loaded models and whether they're on GPU or CPU
ollama stop llama3.1
Unload a model from memory now
ollama show llama3.1
Show parameters, context length, licence
ollama rm llama3.1
Delete a model to free disk space
journalctl -u ollama -f
Follow the server log (useful when something fails)

Use it from code: the API

The service is an HTTP API on http://localhost:11434. A one-off request with curl:

bash
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:

bash
sudo systemctl edit ollama.service

Add the settings you need under [Service], for example:

ini
[Service]
Environment="OLLAMA_MODELS=/data/ollama/models"
Environment="OLLAMA_CONTEXT_LENGTH=8192"

Then reload and restart:

bash
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 the ollama user: 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 check ollama ps afterwards.
  • OLLAMA_KEEP_ALIVE: how long a model stays loaded after the last request (for example 30m, or -1 to 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:

bash
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.

Comments (0)

Leave a Comment
Your email won't be published. We'll only use it to notify you of replies to your comment.
Loading comments...
Previous Article
post-thumb

Jan 24, 2025

The Dark Side of Cloud Computing: Unexpected Costs and Precautions

This article focuses on one of the most common issues: unexpected costs in cloud computing.

Next Article
post-thumb

Jan 17, 2025

Comparing AI Text-to-Image Tools

In this post, we compare and contrast the capabilities and features of various text-to-image AI tools, including DALL-E, Ideogram, Grok, FlexClip, Microsoft Designer, and Deep Dream Generator.

agico

We transform visions into reality. We specializes in crafting digital experiences that captivate, engage, and innovate. With a fusion of creativity and expertise, we bring your ideas to life, one pixel at a time. Let's build the future together.

Copyright ©  2026  TYO Lab · v0.0.40