Skip to content

How to Install Ollama on Ubuntu 24.04 and Run LLMs Locally

Install Ollama on Ubuntu 24.04, run your first local LLM, use the OpenAI-compatible API and expose it safely to your network.

Steps
5
Category
AI & LLMs
Covers
curl, systemd, Ubuntu
Versions & support
About Ubuntu →
On this page 5 steps

Ollama is the easiest way to run large language models (LLMs) on your own machine. One command installs it, one more downloads a model, and you get a chat prompt in the terminal plus a local REST API that other apps can use. Your prompts never leave the server, there are no per-token fees, and it works offline once a model is downloaded.

This guide shows how to install Ollama on Ubuntu 24.04 LTS (Noble Numbat), run your first model, use the API, make Ollama reachable from other machines safely, and keep it updated.

Prerequisites

  • A system running Ubuntu 24.04 (desktop or server), 64-bit x86 or ARM64.
  • At least 8 GB of RAM for small models, 16 GB or more for 7B–8B models.
  • Enough free disk space for models: 2–5 GB each for small models, 40 GB or more for large ones.
  • An NVIDIA or AMD GPU is optional but strongly recommended.
  • A user with sudo privileges.

Step 1 of 5Prepare the NVIDIA GPU Driver

Local models run on the CPU, but a GPU makes them many times faster. If your machine has an NVIDIA card, install the driver before anything else. Ubuntu 24.04 ships the ubuntu-drivers tool, which picks the recommended driver for your card:

sudo apt update
ubuntu-drivers devices
sudo ubuntu-drivers install
sudo reboot

After the reboot, check that the driver sees your GPU:

nvidia-smi

The table lists the GPU model, the driver version and how much memory (VRAM) is free. The CUDA Version field shows the newest CUDA release the driver supports, not a CUDA toolkit installed on the system. See how to install the latest NVIDIA drivers on Ubuntu if you need a specific driver branch.

No NVIDIA GPU? You can still follow this guide on the CPU. Stick to small models (1B to 4B parameters) and expect slower answers.

Step 2 of 5Install Ollama

Ollama publishes an official install script. It downloads the binaries to /usr/local, creates an ollama system user, sets up a systemd service and detects NVIDIA or AMD GPUs. Make sure curl is present, then run the script:

sudo apt install curl -y
curl -fsSL https://ollama.com/install.sh | sh

If you’d rather read the script before running it, download it first with curl -fsSL https://ollama.com/install.sh -o install.sh, review it, and then run sh install.sh.

When the script finishes, confirm the version and that the service is running:

ollama --version
systemctl status ollama

The service should show active (running). Ollama now listens on 127.0.0.1:11434, so only programs on this machine can reach it.

Step 3 of 5Download and Run Your First Model

Models come from the Ollama library. Start with a small one to confirm everything works. llama3.2 is Meta’s 3B-parameter model and needs about 2 GB of disk space:

ollama run llama3.2

The first run downloads the model, then opens an interactive prompt. Type a question and press Enter. Type /bye to exit. Useful commands for managing models:

CommandWhat it does
ollama pull <model>Download a model without starting a chat
ollama listShow downloaded models and their size
ollama psShow loaded models and whether they run on GPU or CPU
ollama stop <model>Unload a model from memory
ollama rm <model>Delete a model from disk
ollama show <model>Show parameters, context length and license

Run ollama ps while a model is loaded. The PROCESSOR column should say 100% GPU on a machine with a supported GPU. A split such as 40%/60% CPU/GPU means the model doesn’t fit in VRAM; pick a smaller model or a lower-precision tag.

Not sure which model fits your GPU? The LLM VRAM calculator estimates the memory a model needs for a given size, quantization and context length.

Step 4 of 5Use the Ollama REST API

Every model you download is also available over HTTP. Send a test request with curl:

curl http://localhost:11434/api/generate -d '{
  "model": "llama3.2",
  "prompt": "Explain what a Linux inode is in two sentences.",
  "stream": false
}' 

Ollama also offers an OpenAI-compatible endpoint at /v1/chat/completions. Most tools and SDKs that support OpenAI can use your local models by setting the base URL to http://localhost:11434/v1 and any non-empty API key:

curl http://localhost:11434/v1/chat/completions 
  -H "Content-Type: application/json" 
  -d '{"model": "llama3.2", "messages": [{"role": "user", "content": "Hello!"}]}' 

Step 5 of 5Allow Access from Other Machines (Optional)

To use Ollama from another computer or from a container, make it listen on all interfaces. Create a systemd override:

sudo systemctl edit ollama

Add these lines in the editor, then save and close it:

[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"

Reload systemd and restart the service:

sudo systemctl daemon-reload
sudo systemctl restart ollama

Important: the Ollama API has no authentication. Anyone who can reach port 11434 can run and delete your models. Allow only trusted addresses with UFW, for example a single office or VPN subnet:

sudo ufw allow from 192.168.1.0/24 to any port 11434 proto tcp

For access over the internet, put Ollama behind a reverse proxy with HTTPS and authentication, or use a chat front end such as Open WebUI, which has its own user accounts.

Change Where Models Are Stored

Models are stored in /usr/share/ollama/.ollama/models. If your root partition is small, move them to a bigger disk with the OLLAMA_MODELS variable. Create the folder, give it to the ollama user, and add the variable to the same override file:

sudo mkdir -p /data/ollama
sudo chown -R ollama:ollama /data/ollama
sudo systemctl edit ollama
[Service]
Environment="OLLAMA_MODELS=/data/ollama"
sudo systemctl daemon-reload
sudo systemctl restart ollama

Update Ollama

Run the install script again. It replaces the binaries and keeps your models and settings:

curl -fsSL https://ollama.com/install.sh | sh

Troubleshooting

  • Model runs on the CPU only: check nvidia-smi works, then read the service log with journalctl -u ollama -e. It reports which GPU it found or why it skipped it.
  • Out of memory errors: use a smaller model or a more compressed tag, or reduce the context length with /set parameter num_ctx 4096 inside the chat.
  • Connection refused from another machine: confirm OLLAMA_HOST is set with systemctl show ollama | grep Environment and that the firewall allows port 11434.

Uninstall Ollama

Stop and remove the service, the binaries, the downloaded models and the service user:

sudo systemctl disable --now ollama
sudo rm /etc/systemd/system/ollama.service
sudo rm -rf /etc/systemd/system/ollama.service.d
sudo rm $(which ollama)
sudo rm -rf /usr/local/lib/ollama /usr/share/ollama
sudo userdel ollama
sudo groupdel ollama

Conclusion

Ollama is now running on Ubuntu 24.04 with a local model and an API that other tools can use. Next, add a browser chat interface with Open WebUI, or move to vLLM when you need to serve many users at once. Running Ubuntu 26.04? Follow the Ubuntu 26.04 guide instead.

Rahul

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top