Running Open-Source LLMs Locally with Ollama: Model Selection, Installation, and Integration
This guide explains when running open-source large language models locally makes sense, how to choose a model size based on available memory, how to install and run Ollama on macOS, Windows, and Linux, and how to confirm that GPU acceleration is working.
1. When Local Deployment Makes Sense
Running open-source models locally has three main benefits. First, your data stays on your own device, which suits sensitive material such as contracts, medical records, and internal code. Second, if you make frequent, long-term calls, you do not pay per token. The upfront hardware cost and electricity can be spread across a large number of requests. Third, you can connect the model to your own scripts and applications and customize it to your needs.
Local deployment also has costs. You need a one-time investment in a GPU or enough memory. Electricity and hardware depreciation count toward the total cost. Open-source models also usually produce lower-quality answers than the latest closed-source models. If you use a model only occasionally, or if your task requires very high answer quality, calling a cloud API directly is often simpler.
Some open-source models natively support function calling, so they can serve as the execution core of an AI agent. On the Ollama model pages, models labeled “tools” support tool calling. Examples include the Qwen2.5 and Llama 3.2 series. If a model does not have this label, you must write your own prompt template, and the results may be less stable. Check the model documentation before you choose a model.
2. Choosing a Model Version by Hardware
The main factor in model selection is available memory. This refers to three cases: unified memory on Apple Silicon devices, VRAM on machines with discrete graphics cards, or system RAM when you run inference on the CPU only. The model weights usually need to be fully loaded into memory or VRAM to run at a good speed. At runtime, the model also needs extra space for the key-value cache (KV cache). The longer the context length, the more memory this cache uses. If there is not enough available memory, Ollama moves some layers to the CPU, and generation becomes noticeably slower.
The table below uses the Q4_K_M quantized versions provided by Ollama as examples. This is 4-bit quantization, the most common approach for local deployment, and it usually causes only a small drop in quality. The file sizes and memory requirements are approximate values for a context of about 4K tokens. Actual usage varies with the version, context length, and operating system. Before you download a model, check the current size of each version at ollama.com/library.
| Model tag (Ollama) | Type | Approx. model file size on disk | Recommended memory (RAM or VRAM) | Suitable hardware |
|---|---|---|---|---|
| gemma3:4b | Dense, image input | About 3.3 GB | 8 GB or more | Low-end laptops, entry-level Macs |
| llama3.2:3b | Dense, tool calling | About 2.0 GB | 6 GB or more | Older laptops, small CPU-only machines |
| qwen2.5:7b | Dense, tool calling | About 4.7 GB | 8 GB or more | Macs with 16 GB unified memory, GPUs with 8 GB VRAM |
| gemma3:12b | Dense, image input | About 8.1 GB | 16 GB or more | Macs with 16 GB unified memory, GPUs with 12 GB VRAM |
| qwen2.5:14b | Dense, tool calling | About 9.0 GB | 16 GB or more | Macs with 24 GB unified memory, GPUs with 16 GB VRAM |
| gemma3:27b | Dense, image input | About 17 GB | 24 GB or more | Macs with 32 GB unified memory, GPUs with 24 GB VRAM |
| qwen2.5:32b | Dense, tool calling | About 20 GB | 32 GB or more | Macs with 48 GB unified memory, dual-GPU or large-VRAM workstations |
To choose a model, first check how much memory you have available. Then pick the largest model from the table that fits, and keep 2 to 4 GB free for the operating system and the context cache. For text summarization or simple question answering, a model around 7B parameters is usually enough. For complex reasoning or long documents, consider a 14B or larger version.
3. Installing and Running Ollama on Mac, Windows, and Linux
macOS: Download the installer from ollama.com/download, drag the app into the Applications folder, and launch it. You can also install the command-line version with Homebrew:
brew install ollama
Windows: Download OllamaSetup.exe and run the installer. Users who prefer the command line can use winget:
winget install Ollama.Ollama
Linux: Use the official install script. Before you run a remote script, download it and review its contents. Run it only after you confirm it is safe:
curl -fsSL https://ollama.com/install.sh -o install_ollama.shless install_ollama.shsh install_ollama.sh
After the installation finishes, open a terminal and check the version:
ollama --version
Next, pull a model and start a conversation. The example below uses gemma3
ollama pull gemma3:4bollama run gemma3:4b "Introduce yourself in one sentence"
Two other useful management commands are ollama list, which shows the models you have downloaded, and ollama rm <model-name>, which deletes a model. By default, models are stored in ~/.ollama/models in your user directory. On Windows, the path is C:\Users\<username>\.ollama\models. If your system drive is running low on space, set the OLLAMA_MODELS environment variable to point to a different directory. Restart the Ollama service after you change this setting.
4. Verifying That GPU Acceleration Is Active
After you download a model, confirm that inference runs on the GPU and not the CPU. The most direct method is to run the following command while the model is running:
ollama ps
The PROCESSOR column in the output shows where the model is running. “100% GPU” means the entire model runs on the GPU. “100% CPU” means the GPU is not being used at all. A mixed result such as “45%/55% CPU/GPU” means VRAM is insufficient, so some layers run in system memory, and generation will be noticeably slower.
You can also cross-check the result with the following methods, depending on your hardware:
- NVIDIA GPUs: While the model is generating text, run
nvidia-smiin another terminal. If the ollama process uses VRAM and GPU utilization rises clearly, acceleration is working. - Apple Silicon: Metal acceleration is enabled by default, so no extra setup is needed. You can watch the GPU load in the GPU History panel of Activity Monitor.
- AMD GPUs (Linux): Run
rocm-smito check VRAM usage and utilization.
If you suspect the GPU is not being used, check the Ollama server logs.
