Local AI with Ollama & LM Studio 🐧🐧🐧

Ollama runs AI language models on your own computer. Your prompts and files stay on your machine, it works offline once a model is downloaded, and there is nothing to pay. It runs on Linux, macOS and Windows, uses your GPU when it can, and falls back to the CPU when it cannot. Prefer a point-and-click app? See LM Studio further down.

Written for Ollama v0.40 (November 2026). New models come out every few weeks, so check the model library for the latest.

Install · Commands · Models for your hardware · Models by task · Configure · Tips · LM Studio · Resources

Install Ollama

# System How / Notes
1 Linux (any distro) curl -fsSL https://ollama.com/install.sh | sh
Sets up a systemd service and an ollama user. Prefer to read a script before running it? curl -fsSL https://ollama.com/install.sh -o install.sh, check it with less install.sh, then sh install.sh. Re-run the same script to update.
2 Arch Linux sudo pacman -S ollama, or ollama-cuda (NVIDIA) / ollama-rocm (AMD) for GPU support. Then sudo systemctl enable --now ollama. Updates come with pacman -Syu.
3 Linux GPU drivers NVIDIA: install the driver/CUDA and check with nvidia-smi. AMD: ROCm v7, ideally with AMD's latest driver. Without a supported GPU Ollama still works, just slower.
4 macOS Download from ollama.com/download, open the .dmg and drag Ollama to Applications. Needs macOS 14 Sonoma or newer. Apple Silicon (M1 and later) uses the GPU; Intel Macs run on the CPU only. Updates install themselves.
5 Windows Download OllamaSetup.exe from ollama.com/download, or run winget install Ollama.Ollama. No administrator rights needed. Needs Windows 10 22H2 or newer; NVIDIA cards need driver 551.61 or newer. Updates install themselves.
6 Check it works ollama -v shows the version. Linux: systemctl status ollama. Mac and Windows: look for the Ollama icon in the menu bar or system tray.

↑ Back to top

Essential Commands

# Command What it does
1 ollama run gemma4 Downloads the model if needed and starts a chat. Type /bye to quit, or /? for help.
2 ollama pull qwen3.5:9b Download a model without starting it. The part after : picks the size; leave it off to get the default.
3 ollama ls List the models you have downloaded and how much disk space each one uses.
4 ollama ps Show loaded models. 100% GPU is fastest; 100% CPU or a CPU/GPU split means the model does not fit in your GPU memory.
5 ollama stop gemma4 Unload a model and free its memory right away. Otherwise models unload after 5 minutes of not being used.
6 ollama rm gemma4 Delete a model from disk. Models are several GB each, so clean up the ones you do not use.
7 ollama run gemma4 "What is in this image? ./photo.png" Ask a vision model about an image by including the file path in the prompt.
8 ollama create mymodel -f Modelfile Build your own variant with a fixed system prompt or settings. A Modelfile can be as short as:
FROM gemma4
SYSTEM """You are a helpful Linux tutor."""
9 ollama launch Sets up coding tools such as OpenCode, Claude Code, Codex or VS Code to use your Ollama models.
10 curl http://localhost:11434/api/generate -d '{"model": "gemma4", "prompt": "Why is the sky blue?", "stream": false}' Ollama runs an API on port 11434. It also speaks the OpenAI API at http://localhost:11434/v1/, so most AI apps and scripts can point at it.

↑ Back to top

Which Model Fits Your Computer?

The model has to fit in memory. For good speed it should fit in your graphics card's memory (VRAM), or on an Apple Silicon Mac in about two-thirds of your RAM. Leave a few GB spare for the context (the conversation so far). The sizes below are the download sizes from the Ollama library.

# Your hardware Good choices (download size)
1 8 GB RAM, no GPU (older laptop, mini PC) llama3.2:3b (2.0 GB), qwen3.5:2b (2.7 GB), qwen3.5:4b (3.3 GB). Expect simple answers at a readable speed; fine for summaries, rewording and quick questions.
2 16 GB RAM, or a GPU with 8 GB VRAM gemma4:e4b (6.6 GB), qwen3.5:9b (6.6 GB), gemma4:12b (7.7 GB), deepseek-r1:8b (5.2 GB). The sweet spot for most home users.
3 32 GB RAM, or a GPU with 16–24 GB VRAM gpt-oss:20b (14 GB), gemma4:26b (16 GB), qwen3.8:27b (18 GB), gemma4:31b (19 GB). Noticeably smarter; good for writing, research and coding.
4 64 GB+ (workstation, or a Mac with lots of unified memory) gpt-oss:120b (65 GB), qwen3.5:122b (81 GB). Close to the big online assistants, but slow without serious hardware.

↑ Back to top

Good Models by Task

# Task Models / Notes
1 Everyday chat and writing gemma4 (Google) and qwen3.5 (Alibaba). Both come in many sizes, understand images, and handle many languages well.
2 Coding qwen3-coder:30b (19 GB) and devstral-small-2 (24B, 15 GB) for code and coding agents. qwen3.6 (27B/35B) is tuned for agentic coding. On smaller machines, qwen3.5:9b is a decent helper.
3 Reasoning, maths and step-by-step problems gpt-oss:20b (OpenAI's open-weight model) and deepseek-r1. They "think" before answering, so they are slower but more careful.
4 Understanding images and screenshots gemma4, qwen3.5 or qwen3-vl (2B–32B).
5 Reading scanned documents (OCR) glm-ocr (2.7 GB) turns scans, receipts and PDFs-as-images into text.
6 Searching your own documents (RAG / embeddings) nomic-embed-text (274 MB) or qwen3-embedding (0.6B–8B). Used by tools like Open WebUI to search your files; not for chatting.
7 Ollama cloud models Tags ending in -cloud, and some very large models, run on Ollama's servers rather than your computer and need ollama signin. Handy for testing big models, but your prompts leave your machine. See tip 3 below to switch cloud features off.

↑ Back to top

Configure Ollama

Ollama is configured with environment variables. First pick the settings you want, then set them the way your system needs (second table).

# Setting What it does / Example
1 OLLAMA_CONTEXT_LENGTH How much text the model can keep in mind at once. The default of 4096 tokens is small; raise it for long documents or coding, e.g. 8192 or 32768. More context uses more memory.
2 OLLAMA_MODELS Where models are stored, e.g. a bigger drive. Defaults: Linux /usr/share/ollama/.ollama/models (install script), macOS ~/.ollama/models, Windows C:\Users\you\.ollama\models. On Linux, give the ollama user access: sudo chown -R ollama:ollama /new/dir.
3 OLLAMA_KEEP_ALIVE How long a model stays loaded after use (default 5m). Use 30m to avoid reload waits, 0 to unload straight away, or -1 to keep it loaded.
4 OLLAMA_HOST Address and port the server listens on (default 127.0.0.1:11434, this computer only). 0.0.0.0:11434 opens it to your network; read tip 1 first.
5 OLLAMA_NO_CLOUD Set to 1 for local-only mode: cloud models and web search are switched off.
6 OLLAMA_KV_CACHE_TYPE q8_0 roughly halves the memory used by the context with very little quality loss. Lets you use a longer context on the same hardware.
7 OLLAMA_FLASH_ATTENTION Used automatically where supported. 1 forces it on, 0 turns it off if you hit problems.
8 OLLAMA_NUM_PARALLEL / OLLAMA_MAX_LOADED_MODELS How many requests one model handles at once (default 1) and how many models can be loaded together. Raising either uses more memory.
9 OLLAMA_ORIGINS Lets extra websites or browser extensions talk to Ollama, e.g. chrome-extension://*,moz-extension://*. Only add what you trust.
10 HTTPS_PROXY / OLLAMA_DEBUG HTTPS_PROXY sends model downloads through a proxy (do not set HTTP_PROXY). OLLAMA_DEBUG=1 adds detail to the logs when troubleshooting.
# System How to set the variables
1 Linux (systemd service) Run sudo systemctl edit ollama and add:
[Service]
Environment="OLLAMA_CONTEXT_LENGTH=8192"
Environment="OLLAMA_KEEP_ALIVE=30m"

Then sudo systemctl daemon-reload && sudo systemctl restart ollama. Logs: journalctl -e -u ollama.
2 macOS (Ollama app) Run one command per variable, e.g. launchctl setenv OLLAMA_CONTEXT_LENGTH 8192, then quit and reopen Ollama from the menu bar. These settings are cleared when the Mac restarts, so run them again after a reboot. Logs: ~/.ollama/logs/server.log.
3 Windows Quit Ollama from the system tray. Open Settings, search for "environment variables", choose "Edit environment variables for your account" and add each one. Or in PowerShell: setx OLLAMA_CONTEXT_LENGTH 8192. Then start Ollama again from the Start menu. Logs: %LOCALAPPDATA%\Ollama\server.log.
4 Just testing (any system) Stop the background service, then start the server by hand with the setting in front: OLLAMA_CONTEXT_LENGTH=8192 ollama serve (Linux/macOS shell).

↑ Back to top

Tips for Using Ollama Safely and Well

# Tip How / Notes
1 Do not expose Ollama to the internet The Ollama API has no password or login. Anyone who can reach port 11434 can use your models and your GPU. Keep the default 127.0.0.1. If you need other devices to connect, allow only your LAN in the firewall, or use a VPN such as WireGuard or a reverse proxy with authentication.
2 Check before opening it to your LAN After setting OLLAMA_HOST=0.0.0.0:11434, check what is listening with ss -tlnp | grep 11434 (Linux) or netstat -ano | findstr 11434 (Windows), and make sure your router does not forward that port.
3 Keep everything local if privacy matters Set OLLAMA_NO_CLOUD=1, or put {"disable_ollama_cloud": true} in ~/.ollama/server.json, and avoid -cloud models. Ollama's logs will then say Ollama cloud disabled: true.
4 Only download models from sources you trust Stick to the official library at ollama.com/library. Community uploads (username/model) can contain anything, including models trained to give harmful advice.
5 Slow answers? Check the GPU Run ollama ps. If it shows CPU, the model is too big for your GPU memory: choose a smaller size, lower OLLAMA_CONTEXT_LENGTH, or set OLLAMA_KV_CACHE_TYPE=q8_0.
6 Model forgetting the start of a long chat or document? The context is too short. Raise OLLAMA_CONTEXT_LENGTH, or inside a chat type /set parameter num_ctx 16384.
7 Stop Ollama starting at login Windows: Task Manager › Startup apps › Ollama › Disable. macOS: System Settings › Login Items › turn off Ollama. Linux: sudo systemctl disable ollama.
8 Want a ChatGPT-style window? The Mac and Windows apps have a built-in chat window. On Linux, or for extras like document search and multiple users, Open WebUI works with Ollama.
9 Keep Ollama updated New models often need a newer Ollama. Mac and Windows update themselves (click "Restart to update"). Linux: re-run the install script, or pacman -Syu on Arch.
10 Double-check what it tells you Local models can sound confident and still be wrong, especially smaller ones. Verify commands before you run them, and never paste AI-written commands into a root shell unchecked.

↑ Back to top

LM Studio: the Point-and-Click Alternative

LM Studio also runs AI models on your own computer, but it is built around a desktop app: you browse, download and chat with models without touching a terminal. It runs the same open models as Ollama (Gemma, Qwen, gpt-oss, DeepSeek and more), so the model advice above applies to both. You can install both side by side. Written for LM Studio v0.4 (November 2026).

# Ollama or LM Studio? The difference
1 Getting started LM Studio: a full desktop app with a model browser, chat window and settings screens. Ollama: a simpler app, but most setup happens in the terminal and with environment variables.
2 Open source? Ollama is open source (MIT licence). The LM Studio app is closed source but free to use at home and for internal work use; its lms command-line tool is open source (MIT).
3 Where models come from Ollama: its own curated library at ollama.com. LM Studio: any compatible model on Hugging Face, so there is far more choice (and more to judge for yourself).
4 Apple Silicon Macs LM Studio can also run Apple's MLX format, which is often faster on M-series Macs. It does not support Intel Macs at all; Ollama does (CPU only).
5 Password on the API LM Studio can require an API token for every request. Ollama's API has no login at all, so it relies on staying on 127.0.0.1 or behind a firewall.
6 Best for LM Studio: trying lots of models, chatting with your documents, people who prefer clicking. Ollama: servers, scripts, Linux services and tools that expect Ollama.
# LM Studio quick guide How / Notes
1 Install on macOS or Windows Download from lmstudio.ai/download and run the installer. macOS: Apple Silicon (M1 or newer) with macOS 14 or newer. Windows: x64 with AVX2 support, or ARM (Snapdragon X). 16 GB RAM recommended; on Windows, a GPU with at least 4 GB VRAM. Updates install from inside the app.
2 Install on Linux Download the AppImage (or the .deb for Debian/Ubuntu) from the same page. Make the AppImage executable and run it: chmod +x LM-Studio-*.AppImage then ./LM-Studio-*.AppImage. If the AppImage will not start, install FUSE 2 (fuse2 on Arch). LM Studio asks for Ubuntu 20.04 or newer (other distros usually work too, and Ubuntu releases after 22.04 are less tested). There is no in-app updater on Linux yet, so download new versions by hand.
3 Download a model Open the Discover tab, search for e.g. gemma, qwen or gpt-oss, and pick a download size that fits your memory (see the hardware table above). In a terminal: lms get openai/gpt-oss-20b, or add --mlx on a Mac.
4 Chat, including with your documents Choose a model at the top of the Chat tab and start typing. You can attach PDFs and text files to a chat; this works fully offline. In a terminal: lms chat.
5 Command-line basics (lms) lms ls lists your models, lms ps shows loaded ones, lms load openai/gpt-oss-20b --gpu=max --context-length=8192 loads one, and lms unload --all frees the memory. Run the app once before using lms.
6 Run the local API server Developer tab › turn on "Start server", or run lms server start. It listens on http://localhost:1234 and speaks the OpenAI API at http://localhost:1234/v1 (and an Anthropic-compatible API), so most AI apps and scripts can use it.
7 Turn on API tokens Developer tab › Server Settings › Require Authentication, then Manage Tokens › Create Token. Copy the token straight away; it is shown only once. Apps then send it as Authorization: Bearer <token>.
8 Sharing it on your network The server only listens on 127.0.0.1 by default. lms server start --bind 0.0.0.0 (or "Serve on Local Network" in Server Settings) opens it to your LAN. Turn on API tokens first, never forward port 1234 on your router, and leave CORS (--cors) off unless a web app really needs it.
9 Run it in the background or on a server In the app: Settings (Ctrl+, / Cmd+,) › run the LLM server on login; closing the window then leaves it running in the tray. For a headless Linux box, install llmster, LM Studio without the desktop app: curl -fsSL https://lmstudio.ai/install.sh | bash (Windows: irm https://lmstudio.ai/install.ps1 | iex), then lms daemon up. Download and read the script first if you prefer.
10 Where models are stored ~/.lmstudio/models by default (%USERPROFILE%\.lmstudio\models on Windows). Change it in the My Models tab, e.g. to a bigger drive.
11 Privacy and offline use Once a model is downloaded, chatting, document chat and the local server all work without internet, and nothing you type leaves your computer. Searching for and downloading models, and update checks, do go online.

↑ Back to top

Resources

# Resource What it is for
1 Ollama download Installers for Linux, macOS and Windows.
2 Ollama model library Browse every model, its sizes and what it can do (vision, tools, thinking).
3 Ollama documentation Official guides, including the API and the FAQ covering every setting on this page.
4 Ollama on GitHub Source code, release notes and bug reports.
5 Open WebUI docs Set up a browser-based chat interface on top of Ollama.
6 LM Studio download Installers for macOS, Windows and Linux, plus the headless llmster.
7 LM Studio documentation Guides for the app, the lms CLI, the API server and API tokens.
8 LM Studio model catalogue Staff-picked models that are known to work well in LM Studio.

↑ Back to top