Run Open-Source LLMs Locally: Hardware Requirements and Installation Guide for macOS, Linux, and Windows
Running large language models locally eliminates per-request API costs, keeps conversation data on your own device, and works even without an internet connection. This guide covers how to choose the right model size based on your memory, verify hardware and driver requirements, install Ollama on macOS, Linux, and Windows, call the local API, troubleshoot common issues, and handle security and licensing considerations.
Running large language models locally eliminates pay-per-use API costs, keeps your conversation data on your own device, and works even when you’re offline. To get everything running smoothly, you need to pick the right model size first, confirm that your hardware and drivers meet the requirements, and then complete the installation and API setup for your operating system. This guide follows that order.
1. Choose a Model Version Based on Memory
The parameter count determines both the model’s capability ceiling and how much memory it consumes. Pick a version that’s too large and the model may fail to load or respond extremely slowly; pick one that’s too small and output quality drops noticeably. The table below uses the DeepSeek-R1 distilled models as an example, with Q4 quantization (4-bit quantization, roughly one quarter the size of the original weights). File sizes come from the Ollama model library and are reference values—always check the official page for current figures.
| Model Tag | Weight File Size | Recommended Minimum RAM/VRAM | Max Context Length | Best For |
|---|---|---|---|---|
| deepseek-r1:1.5b | ~1.1 GB | 4 GB | 128K | Feature testing, older laptops |
| deepseek-r1:7b | ~4.7 GB | 8 GB | 128K | Everyday Q&A and writing |
| deepseek-r1:14b | ~9.0 GB | 16 GB | 128K | Stronger reasoning, mid-range discrete GPUs |
| deepseek-r1:32b | ~20 GB | 24 GB | 128K | Higher output quality, high-end GPUs |
| deepseek-r1:70b | ~43 GB | 48 GB or multiple GPUs | 128K | High-performance workstations |
| deepseek-r1:671b | ~404 GB | Multi-GPU server cluster | 160K | Enterprise deployment |
The recommended values are the lower bounds for stable loading and already include some headroom for the KV Cache. The KV Cache stores intermediate data from the conversation—the longer the conversation, the more it consumes. The maximum context length is simply the longest input the model can accept; it doesn’t mean every conversation will use it all.
Use this order of judgment when selecting a model:
- Less than 8 GB of RAM or VRAM: start with 1.5b.
- 8–16 GB of RAM or VRAM: use 7b. A 16 GB unified-memory machine can also run 14b, but the OS itself uses memory, and response times will slow down when a browser and editor are open at the same time.
- Need higher output quality and have 24 GB or more of VRAM or unified memory: choose 32b.
- When VRAM is insufficient, some model layers are offloaded to system RAM and speed drops significantly. In that situation, switching to a smaller model is usually the better deal.
2. Check Hardware, Drivers, and Ports
Inference speed depends mainly on GPU compute capability and memory bandwidth. Support varies considerably across vendors, so refer to each official compatibility list for specific models.
NVIDIA GPUs: Compute capability must be 5.0 or higher, and the driver should be updated to a recent version. After installing the driver on Windows or Linux, run the following command to check the driver version and VRAM size. In most cases you only need a working graphics driver; whether the CUDA toolkit is also required depends on the framework’s official documentation.
nvidia-smi
AMD GPUs: These rely on ROCm support. Supported models and driver requirements differ between Linux and Windows. Some older or unlisted cards fall back to CPU execution. On Linux, you can use rocm-smi to check GPU status.
Apple Silicon (M-series): The GPU is accessed through Metal, and the CPU and GPU share unified memory, so no separate driver installation is normally needed. The following command shows physical memory size in bytes:
sysctl hw.memsize
Machines without a discrete GPU: In most cases inference runs on the CPU. Small models will work, but slowly—fine for verifying functionality, not for sustained heavy use.
Before installing, confirm each of the following:
- Your OS version meets the framework’s requirements.
- Free disk space exceeds the model file size, with extra room for downloads and temporary files.
- Port 11434 is not occupied by another program.
To check port usage on macOS and Linux:
lsof -i :11434
On Windows PowerShell:
netstat -ano | findstr 11434
If a process is already using the port, either stop that process or change the framework’s listening port.
3. Installation and First Run on All Three Operating Systems
This guide uses Ollama as the local runtime framework. It offers both a graphical installer and a command-line option, and once installed it runs a local service in the background.
macOS
GUI method: Go to the download page at ollama.com, get the .dmg file, drag the app into the Applications folder, and launch it. An icon will appear in the menu bar once it starts successfully.
Command-line method: If you already have Homebrew installed, run the commands below. If you didn’t start the service through the GUI, keep ollama serve running in a terminal window. If the service is already running via the GUI, do not run it again.
brew install ollamaollama serve
Linux
Linux provides a one-line install script. For security, download the script first, review its contents, and then execute it. The script typically requires administrator privileges.
curl -fsSL https://ollama.com/install.sh -o install.shless install.shsh install.sh
After installation, the service is usually managed by systemd. Check its status with:
systemctl status ollama
The default model storage location may be on a partition with limited space. To change it, set the OLLAMA_MODELS environment variable in the systemd service configuration, pointing to a directory with sufficient space.
Windows
Download OllamaSetup.exe from the official site and double-click to install. An icon will appear in the system tray afterward. Then open PowerShell and run:
ollama --versionollama run deepseek-r1:7b
Model files are stored by default in the .ollama folder under the current user’s home directory.
Key differences across the three systems:
- Installer format: macOS uses .dmg, Windows uses .exe, and Linux uses a script or package manager.
- Service management: on macOS and Windows the app typically controls the background service, while on Linux it’s usually managed by systemd.
- Model storage paths differ: refer to the default locations described above, and change them if disk space runs low.
On first run, the framework downloads the model, which takes a while for larger files. Common commands:
ollama pull deepseek-r1:7b # Download only, without runningollama run deepseek-r1:7b # Download and start an interactive chat; type /bye to exitollama list # List downloaded modelsollama ps # Show loaded models and their GPU/CPU allocation ratio
4. Calling the Local API
Once the service is running, it listens on 127.0.0.1:11434 by default and only accepts connections from the local machine. Start by listing the downloaded models:
curl http://localhost:11434/api/tags
Native API
On macOS and Linux, you can send requests directly from the terminal:
curl http://localhost:11434/api/chat -d '{"model":"deepseek-r1:7b","messages":[{"role":"user","content":"Explain KV Cache in one sentence"}],"stream":false}'
Windows PowerShell handles quotes differently from bash, so pasting the command above directly often causes errors. Use the following Python script instead—it works on all three systems:
import requestsresp = requests.post("http://localhost:11434/api/chat",json={"model": "deepseek-r1:7b","messages": [{"role": "user", "content": "Explain KV Cache in one sentence"}],"stream": False,},timeout=120,)resp.raise_for_status()print(resp.json()["message"]["content"])
The timeout is set to 120 seconds because the model can take a long time to load on its first request.
OpenAI-Compatible API
If your application already calls an OpenAI-format API, you only need to change the base URL and model name—the rest of your code stays essentially the same:
from openai import OpenAIclient = OpenAI(base_url="http://localhost:11434/v1/", api_key="ollama")resp = client.chat.completions.create(model="deepseek-r1:7b",messages=[{"role": "user", "content": "Hello"}],)print(resp.choices[0].message.content)
Keep these points in mind when migrating:
- The
modelfield must exactly match a local model tag, such asdeepseek-r1:7b. api_keyis just a placeholder. The local service doesn’t validate it by default, but the SDK usually requires a non-empty value.- Advanced features like function calling and image input depend on whether the specific model supports them—test each one individually.
- R1-series models may include their reasoning process in the response. If you only need the final answer, filter the output in your program.
5. Troubleshooting Common Issues
- Model not found (404): The model isn’t available locally. Run
ollama pull <model tag>to download it. - Connection refused: The service isn’t running. On macOS and Linux, check
ollama serveorsystemctl status ollama; on Windows, check whether the tray icon is present. - First response is very slow: The model needs to load from disk into RAM or VRAM. This is normal, and subsequent requests will be much faster.
- Freezing or out-of-memory errors mid-run: Switch to a model with fewer parameters, or close memory-hungry programs. Use
ollama psto check the model’s running state. - Port already in use: Use the commands from Section 2 to identify the process, or change the listening port and restart the service.
6. Security and Compliance
The default listening address is 127.0.0.1, meaning only local programs can connect. If you want other devices on your LAN to use the service, set the environment variable OLLAMA_HOST=0.0.0.0. This makes the service listen on all network interfaces, and the API itself has no authentication. Do not expose the service directly to the public internet. If remote access is genuinely needed, connect through a VPN first, or put an authenticated reverse proxy in front of it.
If you prefer a graphical chat interface, you can deploy the open-source Open WebUI with Docker and access it at http://localhost:3000:
docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway -e OLLAMA_BASE_URL=http://host.docker.internal:11434 -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main
The --add-host flag is required on Linux. Open WebUI stores chat history in a data volume. Any external services or plugins you enable may send data outside your machine, so review their settings.
Model licenses vary by publisher—some permit commercial use, others impose restrictions. Before using a model in an enterprise or commercial setting, review each model’s license terms individually. Also note that running locally only reduces the chance of data leaving your device; it doesn’t guarantee that logs, caches, or third-party plugins won’t retain data.
7. Summary
Running open-source LLMs on your own machine cuts API costs and keeps data on your device. Real-world performance depends on RAM or VRAM size, quantization method, context length, and background workload. With sufficient VRAM or unified memory and shorter contexts, the 7b and 14b versions work well in practice. Larger versions demand much more powerful hardware and are generally beyond what a personal computer can handle. Follow the sequence in this guide—model selection, hardware check, installation, and API integration—and you’ll have a working local inference environment.
