Run a Local LLM on Ubuntu: Setup, Checks and Security

A local LLM on Ubuntu takes about ten minutes to install and a few more hours to make dependable. You install a runtime, pull a model that fits your GPU memory, confirm it’s really running on the GPU, and keep its unauthenticated API off the network. The chat window is the easy part. What you want is an assistant that can work on the machine itself, and that’s where AILinux 26.05 comes in. It’s an Ubuntu-based distribution that adds an AI layer to the system and lets inference run on interchangeable local or external model providers, while your files and execution stay on your machine.
This guide covers the manual route on a stock Ubuntu install, step by step, with the places it usually breaks.
TL;DR
- Model size is limited by GPU memory first. FP16 weights take roughly 2 GB per billion parameters, and quantization cuts that at some cost in quality.
- On Ubuntu the quickest runtime install is one script that sets up a systemd service with the API on 127.0.0.1:11434.
- A running service proves nothing about where the model executes. Check the processor column and VRAM use before you trust the speed.
- The local API has no authentication, so keep it bound to localhost and reach it remotely through an SSH tunnel or VPN.
- AILinux adds an agent, MCP tools and model routing on top, with permission and approval controls.
Table of Contents
- Check your hardware before you download anything
- Install the runtime and pull a model
- Confirm the model is really running locally, and on the GPU
- Run it as a proper service
- Keep the API private
- Connect the model to the tools you actually use
- Fixing the problems you’ll probably hit
- Skip the glue work with AILinux
- FAQ
- Sources
Check your hardware before you download anything
The first question is how much GPU memory you have. Puget Systems’ hardware primer estimates FP16 weights at about 2 GB per billion parameters, before the context window and runtime overhead. It also says CPU inference can run 10 to 100 times slower than GPU inference. Meta’s Linux guide puts the figure for an 8B Llama model in FP16 at a GPU with at least 16 GB of VRAM.
Most people don’t have 16 GB, and that’s fine, because quantized models store weights at lower precision and shrink the footprint. The cost is a possible drop in quality, which for coding help and sysadmin chores is usually acceptable. NVIDIA’s local-LLM playbook gives these starting points:
| GPU memory | Starting model family |
|---|---|
| 6 to 8 GB | Qwen 3.5 4B |
| 12 to 16 GB | Qwen 3.5 9B or Gemma 4 12B |
| 24 GB or more | Qwen 3.6 27B |
Treat those as starting points. Pick a model that fits with room to spare, because the context cache and compute buffers also eat memory. A model that loads fine can still fail on its first long prompt.
On an NVIDIA card, run nvidia-smi first. If it doesn’t list your GPU and driver, nothing downstream will use the card. Linuxize’s October 2026 Ubuntu guide says Ollama needs an NVIDIA GPU with compute capability 5.0 or newer and driver 550 or newer, and that older 5.0 to 6.2 cards need driver 570 or newer. It also says you don’t need the full CUDA Toolkit for inference. No GPU at all? You can still run small models on CPU and system RAM. Start tiny and step up while you watch memory.

Install the runtime and pull a model
On Ubuntu, the least fiddly runtime is Ollama. Its official installer is one line:
curl -fsSL https://ollama.com/install.sh | sh
Per Arct Cloud’s Ubuntu 24.04 tutorial, the script puts the binary in /usr/local, creates an ollama system user, and registers and starts a systemd service with the API at 127.0.0.1:11434. The installer output ends by saying the API is available at that address. Piping a script into a shell is a trust decision, so read it first if the machine matters.
Then get a model. ollama pull MODEL downloads without chatting, and ollama run MODEL downloads if needed and opens a chat, as Linuxize explains. For a first test, pick something small that fits on any machine:
ollama pull llama3.2
ollama run llama3.2
List what you have with ollama ls, and inspect a model’s metadata with ollama show MODEL. Models from the system service live under /usr/share/ollama/.ollama/models by default. If your root partition is small, set OLLAMA_MODELS to point at a bigger disk before you pull anything large, since a single quantized model can run into several gigabytes.
There are other ways in. You can build a C++ inference engine from source with build-essential, Git and CMake, which gives you more control and more maintenance. You can run a Python-based serving stack in a virtual environment, which suits multi-user GPU servers more than a laptop. For one developer or admin on one machine, the single-script route is the sensible default.
Confirm the model is really running locally, and on the GPU
Start with the service. curl http://localhost:11434 should answer “Ollama is running”. Then run a real prompt through the API:
curl http://localhost:11434/api/generate -d '{"model":"llama3.2","prompt":"Say hello"}'
The next check catches the most common silent failure. Run ollama ps while a model is loaded and read the PROCESSOR column. It should say 100% GPU. If it says CPU, this Ubuntu 26.04 NVIDIA walkthrough says to fix the driver (nvidia-smi must work) and then reinstall Ollama so it detects the GPU again. In a second terminal, nvidia-smi should show the ollama process holding VRAM while it answers.
Why bother? Because iLogr’s Ubuntu write-up points out that systemd can’t tell you where a model executes: a service that fell back to CPU looks identical to a healthy one, and a service restarted onto a different model file passes every health check while doing the wrong job. If you depend on the setup, run a scheduled test prompt that asserts both a latency ceiling and a plausible answer. A cron job and a ten-line script are enough.
A reply that takes forty seconds for a short answer usually means CPU fallback, not a weak model.
Run it as a proper service
Because the installer registers a systemd unit, you manage it like any other daemon:
systemctl status ollama --no-pager
sudo systemctl restart ollama
journalctl -u ollama -f
The status should show Active: active (running). Environment settings such as the bind address or model directory belong in a systemd drop-in override (sudo systemctl edit ollama), not in edits to the packaged unit file, so updates don’t wipe them. Re-run the install script to update, then check ollama -v and your test prompt again.
If you run a bare inference server instead, write the unit yourself. One 2026 Ubuntu deployment runs its server as an unprivileged user with Restart=on-failure, a five-second restart delay and an API-key file with restrictive permissions. Those are good defaults to copy.
If you set memory limits in the unit, know that LLM servers behave oddly under them. SSD Nodes explains that the model file is memory-mapped, so the kernel can evict and re-read its pages, while the KV cache (the working memory for your conversation) can’t be dropped. That makes MemoryHigh a soft slowdown and MemoryMax an invitation for the OOM killer. The same article warns that leaving the context length at its default of 0, meaning the model’s full trained context, can allocate a huge cache and kill the service before it answers anything. Set a context length explicitly.

Keep the API private
The local API has no authentication. Anyone who can reach port 11434 can run prompts, pull models until the disk fills, and delete the ones you have. The Arct Cloud tutorial pins OLLAMA_HOST=127.0.0.1:11434 in a systemd drop-in and sets OLLAMA_NO_CLOUD=1 so prompts stay on the machine. Verify with ss -tln: you want to see 127.0.0.1:11434, and a line showing 0.0.0.0:11434 means the API is exposed to the network.
For remote access, use an SSH tunnel or a VPN. If you need a browser front end for several people, put it behind a reverse proxy with HTTPS and a login. The AI Atlas guide gives the same advice: never expose the raw port to the internet. On a server with UFW, open only SSH, 80 and 443.
Connect the model to the tools you actually use
A terminal chat is a demo. The payoff comes when your editor, scripts and automation call the model. Ollama exposes an OpenAI-compatible endpoint at http://localhost:11434/v1/, per the AI Atlas guide, so anything that lets you set a custom base URL can point at it. Most coding assistants and chat front ends do.
The weak spot is what the model can do. A chat window can write a shell command, but you still copy, paste and judge it. Giving a model direct tool access, to read a repository, search, run a command or check a service, needs permissions and approvals, or you’ve built a very confident intern with root.
That gap is what AILinux is built around. Its agent works on Linux through MCP tools (a standard way of exposing code, workspace, memory, search and device functions to a model) with configurable permissions and approval controls, so AI work isn’t confined to a browser chat. Model routing lets you send a task to a local model or an external provider and swap them without rebuilding your workflow. For the background on this approach, the Linux AI overview on the AILinux blog walks through running AI locally on Linux.
Fixing the problems you’ll probably hit
The model runs but it’s slow. Check ollama ps. If it says CPU, fix the driver as described above. If it splits between CPU and GPU, the model plus its cache doesn’t fit in VRAM: pick a smaller quantization or a smaller model.
It loads, then fails on a real request. Weights, KV cache and compute buffers all take GPU memory, and loading successfully doesn’t guarantee a long prompt will fit. Shorten the context or step down a model size.
The GPU isn’t detected after a driver change. Get nvidia-smi working, then reinstall the runtime so it re-detects the card.
The disk fills up. Models are large. Move storage with OLLAMA_MODELS and remove what you don’t use.
Another machine can reach the API. Run ss -tln, look for 0.0.0.0:11434, and rebind to localhost.
A good habit is to step up in size. One Qwen Ubuntu guide starts with a tiny 0.6B example and measures memory as the model sizes grow, instead of trusting a table of minimums. Your own measurement on your own card beats any chart.
Skip the glue work with AILinux
Everything above is the plumbing: runtime, service, verification, lockdown, wiring. If you want a system where the AI layer is part of the operating system, AILinux covers this ground. It’s an Ubuntu-based distribution with a system agent for coding, DevOps, system administration and task verification, plus a desktop AI client and MCP tools for code, workspace, memory, search, devices and automation.

You can download AILinux 26.05, or browse AI Coder, TriForce MCP Server and the other products if you’d rather add the agent tooling to a setup you already have.
FAQ
How much VRAM do I need to run a local LLM on Ubuntu?
A rule of thumb is about 2 GB per billion parameters at FP16, plus overhead for context. An 8B model in FP16 wants roughly 16 GB, per Meta’s guide. Quantized versions need much less, and 6 to 8 GB cards are comfortable with a roughly 4B model.
Can I run a local LLM on Ubuntu without a GPU?
Yes. Inference runs on CPU and system RAM, but it can be 10 to 100 times slower than on a GPU, according to Puget Systems. Small models are still usable for short tasks. Begin with a tiny model and increase the size while watching memory.
How do I know the model is running locally and not in the cloud?
With Ollama, ollama ps shows the loaded model and its processor, and ss -tln should show the API on 127.0.0.1 only. Setting OLLAMA_NO_CLOUD=1 keeps prompts on the machine. nvidia-smi confirms the GPU is doing the work.
Is it safe to expose the local API to my network?
Not directly. The API has no authentication, so anyone who reaches it can run prompts and delete models. Keep it on localhost and use an SSH tunnel or VPN, or put an authenticated HTTPS proxy in front of it.
Sources
- Tech Primer: What hardware do you need to run a local LLM?
- Running Llama on Linux
- Run Local LLMs, NVIDIA Playbooks
- How to Install and Use Ollama on Ubuntu 26.04 and 24.04
- Install Ollama on Ubuntu 24.04 with Open WebUI
- Install Ollama on Ubuntu 26.04 with an NVIDIA GPU
- Running Local Language Models on Ubuntu
- Serving Local LLMs on Ubuntu 26.04 with an RTX 5060 Ti 16 GB
- Run the llama.cpp server on a VPS
- How to Run an LLM Locally (2026 Guide)
- Install Qwen on Ubuntu 26.04 and 24.04


