Short answer: A self-hosted LLM on a VPS needs a runtime such as Ollama, a quantized open model and enough memory for it: about 8 GB of RAM for a 7–8B model at Q4_K_M, 16 GB for 14B and 32 GB for 32B. CPU-only plans work, slowly; a GPU is faster but costs more. 16 GB plans start at $10.02 a month.
A self-hosted LLM is an open-weight language model that runs on hardware you control, here a rented VPS, instead of behind someone else's API. This guide covers how much RAM or VRAM each model size needs, what CPU-only servers can do, and how to install Ollama on Ubuntu, pull a model and keep its API off the public internet.
It ends with costs from our data on 199 providers and when a pay-per-token API is cheaper.
What does a self-hosted LLM need?
A self-hosted LLM needs four parts: a runtime that loads the model and serves an API (Ollama, or llama.cpp underneath it), a model file in a quantized format such as GGUF, enough memory to hold that file plus its context, and a way to reach the API without exposing it. Memory decides which models you can run; processor speed decides how fast they answer.
Ollama is the usual runtime on a VPS. It downloads models from its library with one command, keeps them in memory between requests and serves a REST API on port 11434. Open WebUI can sit on top as a chat interface, and agent tools such as OpenClaw can use the same API (see how to install OpenClaw).
Can you run an LLM on a VPS without a GPU?
Yes, you can run an LLM on a VPS with CPU only, and for small models that is the cheapest way to self-host LLM inference. Without a GPU, Ollama loads the weights into system RAM and the CPU does the maths.
What speed to expect on CPU
Each generated token means reading the model's active weights from memory, so CPU speed falls as models grow and depends more on memory bandwidth than on core count. In practice:
- 1–4B models feel responsive on a few vCPUs and suit chat, classification and summaries.
- 7–8B models are usable for chat but noticeably slower, and long prompts add a delay before the first word.
- 14B and larger models are better treated as batch jobs that run in the background.
Reasoning models such as DeepSeek-R1 write a chain of thought before the answer, which multiplies the wait on CPU. Measure on your own plan: ollama run <model> --verbose prints prompt and generation rates in tokens per second after each reply.
Two VPS-specific checks help. llama.cpp uses AVX, AVX2 and AVX-512 on x86, and some hypervisors hide them, so check with grep -o -w 'avx2\|avx512f' /proc/cpuinfo | sort -u. And inference holds every core at 100% while it runs; shared-vCPU plans often limit sustained full load in their acceptable use policy, so read it or pick a dedicated-CPU VPS.
When a GPU is worth it
A GPU is worth it when you need fast interactive answers from models above about 8B, or several users at once. The model must fit in VRAM: when it does, ollama ps shows 100% GPU in the Processor column; when it spills into system RAM, speed drops sharply. Ollama supports NVIDIA cards with compute capability 5.0 or newer, AMD cards through ROCm, and others through Vulkan.
GPU plans are rarer and pricier. As of November 30, 2026, 41 of 199 providers in our data sell them; compare them in our AI VPS ranking of GPU plans or browse every GPU VPS provider.
How much RAM or VRAM does an LLM need?
At Q4_K_M, the quantization most Ollama default tags use, an LLM needs about 0.6 GB of memory per billion parameters for its weights, plus roughly 1–2 GB for the context cache and runtime at the default context, plus whatever the OS and other services use. The same figure applies to VRAM on a GPU and to disk space for the download.
The 0.6 GB rule comes from llama.cpp's own measurements. Its quantize tool lists Q4_K_M at 4.89 bits per weight, which shrinks Llama 3.1 8B from 32.1 GB to 4.9 GB and Llama 3.1 70B from 280.9 GB to 43.1 GB. The README also notes that memory and disk requirements are the same, because the whole file is loaded.
Quantization levels compared
Lower-bit quantizations save memory at some cost in output quality. These are llama.cpp's figures for Llama 3.1 8B:
| Quantization | Bits per weight | File size (8B model) |
|---|---|---|
| F16 | 16.0 | 14.96 GiB |
| Q8_0 | 8.50 | 7.95 GiB |
| Q6_K | 6.56 | 6.14 GiB |
| Q5_K_M | 5.70 | 5.33 GiB |
| Q4_K_M | 4.89 | 4.58 GiB |
| Q3_K_M | 4.00 | 3.74 GiB |
| Q2_K | 3.16 | 2.95 GiB |
Q4_K_M is the usual balance. Q5_K_M or Q8_0 are worth it when RAM allows; Q3 and Q2 squeeze a model into less memory, and quality drops noticeably at Q2_K.
Context length also costs memory
The context cache grows with the context window. Ollama's FAQ gives a default context of 4096 tokens and says required RAM scales with OLLAMA_NUM_PARALLEL times OLLAMA_CONTEXT_LENGTH, so raising either one raises memory use. If you need long contexts on limited RAM, OLLAMA_KV_CACHE_TYPE=q8_0 (with Flash Attention enabled) uses about half the cache memory of the default f16.
Sizing table: model size, RAM and VPS plan
The download sizes below are approximate, worked out from the 4.89 bits per weight for Q4_K_M; real files vary by a few hundred MB with the architecture. Minimum RAM assumes one model, the default context and a lean Ubuntu server. Ollama's earlier README gave the same floors of 8 GB for 7B, 16 GB for 13B and 32 GB for 33B models.
| Model size | Examples on Ollama | Q4_K_M download | Minimum RAM (CPU) | Typical VPS plan | Lowest listed price |
|---|---|---|---|---|---|
| 1–4B | llama3.2:3b, qwen3:4b, gemma3:4b | 1–3.5 GB | 4 GB | 2–4 vCPU, 4–8 GB | $3.00 |
| 7–9B | llama3.1:8b, qwen3:8b, deepseek-r1:8b | 4.5–5.5 GB | 8 GB | 4 vCPU, 8–16 GB | $6.00 |
| 12–14B | gemma3:12b, qwen3:14b, deepseek-r1:14b | 7.5–9.5 GB | 16 GB | 4–8 vCPU, 16 GB | $10.02 |
| 24–32B | mistral-small3.2:24b, gemma3:27b, qwen3:32b | 15–20 GB | 32 GB | 8 vCPU, 32 GB | $19.95 |
| 70B | llama3.3:70b, deepseek-r1:70b | about 43 GB | 64 GB | 8+ vCPU, 64 GB, or a GPU with 48 GB+ VRAM | $37.89 |
Prices are each tier's cheapest Linux plan in our data as of November 30, 2026; some require annual prepayment. Disk matters as much as RAM: models live in /usr/share/ollama/.ollama/models, and keeping two or three of them can take 30 GB or more.
Which open models can you self-host in 2026?
The model families people run on a VPS in October 2026 are Llama, Qwen, Gemma, Mistral and the DeepSeek-R1 distills. All are in the Ollama library under these names:
| Family | Ollama library names | Sizes listed | Good fits for an 8–16 GB CPU plan |
|---|---|---|---|
| Llama (Meta) | llama3.2, llama3.1, llama3.3, llama4 | 1b, 3b; 8b, 70b, 405b; 70b; 16x17b, 128x17b | llama3.2:3b, llama3.1:8b |
| Qwen (Alibaba) | qwen3, qwen3.5, qwen3.6 | 0.6b–235b; 0.8b–122b; 27b, 35b | qwen3:4b, qwen3:8b, qwen3.5:9b |
| Gemma (Google) | gemma3, gemma4 | 270m–27b; e2b, e4b, 26b, 31b | gemma3:4b, gemma3:12b |
| Mistral | mistral, ministral-3, mistral-small3.2 | 7b; 3b, 8b, 14b; 24b | mistral:7b, ministral-3:8b |
| DeepSeek-R1 distills | deepseek-r1 | 1.5b, 7b, 8b, 14b, 32b, 70b (plus the full 671b) | deepseek-r1:8b, deepseek-r1:14b |
Two cautions. Llama 4 is a mixture-of-experts model whose smallest version still has far more total parameters than a typical VPS can hold. And some library entries carry a cloud tag, meaning certain variants run on Ollama's servers rather than yours; the privacy section below shows how to switch those off.
How to self-host an LLM on a VPS with Ollama
The steps below use Ubuntu 24.04 LTS or 26.04 LTS and a plan with at least 8 GB of RAM. They take about 30 minutes, most of it waiting for the model download.
Step 1: Prepare the Ubuntu server
Log in as a sudo user, update the system and allow only SSH through the firewall. Then check what the plan really provides.
sudo apt update && sudo apt upgrade -y
sudo ufw allow OpenSSH
sudo ufw enable
free -h && nproc && df -h /
Step 2: Install Ollama with the official script
Ollama's Linux docs give a one-line installer. On a systemd system it creates an ollama user and service, which starts at boot.
curl -fsSL https://ollama.com/install.sh | sh
systemctl status ollama
ollama -v
The service should show active (running). To update later, run the same script again. Logs are in journalctl -e -u ollama.
Step 3: Pull and run a model
Pick a model from the sizing table that leaves a few GB of RAM free. This example uses the 8B DeepSeek-R1 distill, a 5.2 GB download.
ollama pull deepseek-r1:8b
ollama run deepseek-r1:8b --verbose
Type a question, read the timing lines, and leave the chat with /bye. ollama ps shows what is loaded and whether it sits on CPU or GPU; ollama list and ollama rm <model> manage downloads. Models stay in memory for 5 minutes after the last request unless you change OLLAMA_KEEP_ALIVE.
Your own code talks to the REST API on localhost:
curl http://localhost:11434/api/generate -d '{
"model": "deepseek-r1:8b",
"prompt": "Explain swap space in two sentences.",
"stream": false
}'
Ollama also serves OpenAI-compatible endpoints under /v1, so many existing SDKs and tools work by changing the base URL.
Step 4: Keep the API private
Ollama binds to 127.0.0.1 on port 11434 by default and has no built-in authentication, so leave it there. Confirm it:
ss -tlnp | grep 11434
The output should show 127.0.0.1:11434, not 0.0.0.0 or *. For your own use, an SSH tunnel from your computer forwards local port 11434 to the server without opening anything:
ssh -N -L 11434:localhost:11434 user@SERVER_IP
If the server sits on a WireGuard, Tailscale or provider private network, bind Ollama to that private address only. Run sudo systemctl edit ollama.service, add the lines below, then run sudo systemctl daemon-reload && sudo systemctl restart ollama. Avoid 0.0.0.0, which listens on the public interface too.
[Service]
Environment="OLLAMA_HOST=10.0.0.5:11434"
For apps on other machines, put a reverse proxy with a password in front. Ollama's FAQ shows an Nginx proxy_pass setup; this version adds HTTP basic authentication:
sudo apt install nginx apache2-utils
sudo htpasswd -c /etc/nginx/.htpasswd alice
server {
listen 80;
server_name llm.example.com;
location / {
auth_basic "Ollama";
auth_basic_user_file /etc/nginx/.htpasswd;
proxy_pass http://localhost:11434;
proxy_set_header Host localhost:11434;
}
}
Save it as /etc/nginx/sites-available/ollama, link it into sites-enabled, then run sudo nginx -t && sudo systemctl reload nginx and sudo ufw allow 'Nginx Full'. Add a TLS certificate before using it over the internet, because basic auth over plain HTTP sends the password in clear text. Our VPS security checklist covers SSH keys and the rest of the hardening.
Step 5: Add Open WebUI
Open WebUI is a browser chat interface with user accounts and model switching. Install Docker Engine from Docker's Ubuntu instructions first. A container cannot reach an Ollama that listens only on the host's 127.0.0.1, and Open WebUI's troubleshooting guide fixes that with host networking:
openssl rand -hex 32 > ~/.webui_secret
docker run -d --network=host \
-v open-webui:/app/backend/data \
-e OLLAMA_BASE_URL=http://127.0.0.1:11434 \
-e WEBUI_SECRET_KEY="$(cat ~/.webui_secret)" \
--name open-webui --restart always \
ghcr.io/open-webui/open-webui:main
With host networking the interface listens on port 8080. The firewall from step 1 keeps that port closed to the internet, so open it through a tunnel (ssh -N -L 8080:localhost:8080 user@SERVER_IP) and browse to http://localhost:8080. Create your account straight away: the first account becomes the administrator, and sign-ups switch off after that. Keep the secret key file, because a new key logs everyone out.
How to run DeepSeek with Ollama on a VPS
To run DeepSeek with Ollama on a VPS, install Ollama as above, pull a distilled deepseek-r1 tag and size the plan to it. The tags are different models:
deepseek-r1:1.5b,7b,14band32bare distills built on Qwen 2.5.deepseek-r1:8bis DeepSeek-R1-0528-Qwen3-8B, built on Qwen3.deepseek-r1:70bis built on Llama 3.3 70B Instruct.deepseek-r1:671bis the full model; at Q4_K_M it works out to roughly 400 GB, beyond any normal VPS.
Use the 8b tag on 8 GB, 14b on 16 GB and 32b on 32 GB. Answers take longer than from a non-reasoning model of the same size, because R1 thinks out loud first.
Common errors and fixes
- The model stops loading or the process dies silently. The kernel's out-of-memory killer usually ended it. Check with
sudo dmesg -T | grep -i -E 'killed process|out of memory', then pick a smaller model or quantization, or lower the context length. - Answers are far slower than expected.
100% CPUinollama psis normal on a CPU plan, but a highst(steal) value intopmeans the host is overcommitted. A smaller model or a dedicated-CPU plan helps more than extra cores. - Open WebUI shows an empty model list. The container cannot reach Ollama: check
--network=host,OLLAMA_BASE_URL=http://127.0.0.1:11434andsystemctl status ollama. - Port 11434 answers from the internet. Someone set
OLLAMA_HOST=0.0.0.0; remove it withsudo systemctl edit ollama.service, restart and re-check withss -tlnp. Ports published with Docker's-pflag bypass ufw, so publish them to127.0.0.1only. - The disk fills up. Remove unused models with
ollama rm, or move the store to a bigger volume with theOLLAMA_MODELSenvironment variable.
What does it cost to self-host an LLM on a VPS?
A CPU-only VPS for a 7–8B model starts at $6.00 a month for 8 GB of RAM, and typical prices are several times higher. As of November 30, 2026, 173 providers in our data sell a plan with at least 16 GB, from $10.02 a month. The median provider's cheapest 32 GB plan costs $117.15, while the low end of the market costs far less. These are the five cheapest plans with 32 GB of RAM and at least 40 GB of disk, enough for a 32B model plus the OS:
| # | Provider | Plan | Specs | Price / month |
|---|---|---|---|---|
| 1 | LikeVPS | HP Like+ | 12 vCPU, 32 GB RAM, 600 GB SSD, unmetered traffic | $67.00 |
| 2 | ServerCheap | NVMe-KVM-34GB | 8 vCPU, 34 GB RAM, 200 GB NVMe, 6 TB traffic | $23.99 |
| 3 | Psychz Networks | cVirtual Enhanced | 4 vCPU, 32 GB RAM, 50 GB NVMe, unmetered traffic | $24.00 |
| 4 | AlphaVPS | C32G | 8 vCPU, 32 GB RAM, 240 GB NVMe, 20 TB traffic | $25.60 |
| 5 | Contabo | Cloud VPS 12 | 12 vCPU, 48 GB RAM, 400 GB SSD, unmetered traffic | $27.66 prepaid annually or longer |
Check the disk size before buying: a 32B model needs about 20 GB on its own, and some high-RAM plans come with small disks.
These are the top plans in our best VPS for Ollama ranking, which requires at least 8 GB of RAM:
| # | Provider | Plan | Specs | Price / month | Locations |
|---|---|---|---|---|---|
| 1 | LikeVPS | Start | 4 vCPU, 8 GB RAM, 100 GB NVMe, unmetered traffic | $23.00 | 26 |
| 2 | Contabo | Cloud VPS 4 | 4 vCPU, 8 GB RAM, 100 GB SSD, unmetered traffic | $6.09 prepaid annually or longer | 10 |
| 3 | netcup | VPS Lite 2 G12.5s | 4 vCPU, 8 GB RAM, 160 GB SSD, unmetered traffic | $8.82 | 5 |
| 4 | HOSTKEY | Hourly VPS Business | 4 vCPU, 8 GB RAM, 100 GB SSD | $7.20 | 7 |
| 5 | OVHcloud VPS | VPS-2 | 4 vCPU, 8 GB RAM, 75 GB NVMe, unmetered traffic | $8.50 | 11 |
Top 5 of 190 providers in our Best VPS for Ollama and Local LLMs ranking, updated November 30, 2026. Each plan meets the software's published minimum requirements.
GPU servers sit in a different price band, and only 41 providers offer them.
When is an API cheaper than self-hosting?
An API is cheaper when your volume is low or uneven. A VPS bills by the month whether it answers one request or a million, while an API bills per token, so for occasional questions and prototypes the API almost always wins.
Self-hosting starts to make sense when one of these holds:
- You send a steady, high volume of simple requests (tagging, extraction, summaries) that a 4–14B model handles well.
- Data may not leave your infrastructure for contractual or regulatory reasons.
- You want fixed monthly costs and no dependence on an outside API's uptime or rate limits.
- You need a specific open model, a fine-tune, or control over versions.
Quality is the other side of the ledger. A 7–8B model on a CPU will not match the largest hosted models on hard reasoning or long coding tasks, so test your real prompts on both.
What privacy does a self-hosted LLM give you?
Your prompts and outputs stay on your server. Ollama's FAQ states that when you run models locally it does not see your prompts or data, which removes a third party from the flow of customer data, internal documents and anything under an NDA.
The VPS provider still controls the hypervisor and the disks, so its location, privacy policy and data processing terms matter. Ollama also offers cloud models; to keep a server local-only, add Environment="OLLAMA_NO_CLOUD=1" with sudo systemctl edit ollama.service and restart. Open WebUI keeps chat history in its Docker volume, so cover that volume in your backup and retention plans.
Model licences differ
Open weights do not mean one licence. Read each model's licence before you build a product on it; ollama show <model> --license prints it, and the Hugging Face model card states it too.
The DeepSeek-R1 family shows how mixed it gets. The R1 weights are MIT-licensed, which allows commercial use and derivatives. The Qwen-based distills come from Qwen 2.5 (originally Apache 2.0), while the Llama-based distills inherit Meta's Llama 3.1 or 3.3 licence, which adds conditions that MIT and Apache 2.0 do not. Other families have their own terms, so check each tag you deploy.
Which setup should you choose?
For a private assistant or a background worker, a CPU VPS with 16 GB of RAM running an 8B or 14B model through Ollama is the practical starting point. Keep the API on localhost, use Open WebUI through a tunnel, and measure tokens per second with --verbose before you scale. Move to 32 GB for 27–32B models, and to a GPU plan when you need fast answers from big models or several users at once. If your usage is light, a hosted API will cost less until the volume grows.
Frequently asked questions
How much RAM do I need to self-host an LLM?
At the common Q4_K_M quantization a model needs roughly 0.6 GB per billion parameters, plus room for the context cache and the OS. In practice that means 8 GB of RAM for a 7–8B model, 16 GB for 13–14B, 32 GB for 27–32B and 64 GB for 70B. See the best VPS for Ollama.
Can I run an LLM on a VPS without a GPU?
Yes. Ollama and llama.cpp run models on the CPU from system RAM. Small models (1–8B) are usable for chat and background jobs; 14B and larger are slow on CPU and suit batch work better. For fast interactive use with bigger models, rent a GPU plan instead.
Is a self-hosted LLM private?
Prompts stay on your server when you run models locally, and Ollama's FAQ says it does not see local prompts or data. The VPS provider still controls the hardware, so pick a jurisdiction and provider you trust, and set OLLAMA_NO_CLOUD=1 if you want to block Ollama's cloud models.
Is it safe to set OLLAMA_HOST=0.0.0.0 on a VPS?
Not on its own. The Ollama API has no built-in authentication, so binding it to all interfaces exposes it to the internet. Keep the default 127.0.0.1:11434 and use an SSH tunnel, a private network address or a reverse proxy with a password and TLS.
How do I run DeepSeek with Ollama on a VPS?
Install Ollama, then run ollama run deepseek-r1:8b for an 8–16 GB plan or deepseek-r1:14b for 16 GB and up. These tags are distilled models built on Qwen; the full 671b model needs hundreds of gigabytes and is not practical on a VPS.
Is self-hosting an LLM cheaper than using an API?
Usually not at low volume, because a VPS costs the same whether it is busy or idle and small open models need more hardware per answer. Self-hosting pays off with steady high volume, strict data rules, or work that a small model handles well. Compare plans in our AI VPS ranking.
Sources
Commands and requirements were checked against these pages on November 30, 2026. Prices and plan tables in the article come from our provider data, updated the same day.
- Ollama: Linux installation
- Ollama FAQ
- Ollama: GPU support
- Ollama README v0.5.7 (RAM guidance by model size)
- Ollama model library
- Ollama library: deepseek-r1
- llama.cpp: quantize tool README
- llama.cpp README
- Open WebUI: Quick Start
- Open WebUI on GitHub (troubleshooting)
- NGINX: Restricting access with HTTP basic authentication