Running Open-Source LLMs Locally on Limited Memory: Model Selection and Setup Guide
This guide explains how to run open-source large language models on a personal computer with limited memory. It covers choosing a model size and quantization level based on available memory, a reference table for common memory sizes, and installing, pulling, and verifying models with Ollama. It also includes common troubleshooting tips.
1. What This Article Covers
This article does not promise that a full-activation model with hundreds of billions of parameters will run on a personal computer. Personal devices typically have 8 to 64 GB of memory, and the mainstream models that run stably fall between 4 billion and 30 billion parameters. This article explains how to choose a model size based on memory, how to install and pull a model, how to verify that it runs, and how to connect a local model to an application.
Running a model locally has three main benefits:
- No token fees: you pay no per-call charges, so the long-term marginal cost is roughly electricity and hardware depreciation.
- Data stays on your machine: sensitive text never passes through third-party servers, which helps meet internal compliance requirements.
- Customization: you can apply quantization and fine-tuning, and connect your own knowledge base, without being limited by cloud service quotas.
Local deployment also has trade-offs. It cannot scale elastically, so the hardware limit is the service limit. Users need to know their machine’s resources clearly.
2. Model Selection: Check Memory First, Then Quantization
2.1 Memory Determines What You Can Run
A model file’s size is roughly its parameter count multiplied by the bytes used per parameter. With 4-bit quantization, every 1 billion parameters takes about 0.5 to 0.6 GB. Actual runtime usage also includes the KV cache and the operating system’s own usage. The longer the context, the larger the cache. On Apple Silicon, memory is shared between the CPU and GPU. The system and other apps use the same memory, so usable memory is noticeably smaller than the advertised figure.
A practical rule of thumb is that available memory should be at least 30% to 50% larger than the model file. This is an empirical guideline, not an exact formula. Confirm it against actual memory usage at runtime.
2.2 Quantization: Trading a Little Precision for Smaller Size
Quantization compresses model weights from FP16 to lower bit widths, such as 8-bit or 4-bit. Large model weights tend to cluster within a narrow range of values, so approximating them with fewer bits causes little noticeable quality loss on most tasks. Memory footprint and bandwidth requirements drop substantially.
- 4-bit (such as Q4_K_M): the smallest size, suitable for most consumer devices, with a possible slight drop in complex reasoning.
- 8-bit: smaller quality loss, but roughly twice the size of 4-bit.
- MoE (Mixture of Experts): large total parameter count, but only a subset of experts is activated per inference. For example, a model with 30 billion total parameters and 3 billion active parameters runs at speeds close to a small model and delivers higher quality than a dense model with the same active size. The trade-off is that all weights must stay resident in memory.
2.3 Reference Table for Choosing a Model by Memory
The table uses the 4-bit quantized versions that Ollama provides by default. The sizes shown are model file sizes. Actual usage also includes context overhead.
| Available Memory | Recommended Model Tag (example) | Model File Size (approx.) | Typical Use |
|---|---|---|---|
| 8 GB | qwen3:4b | 2.5 GB | Everyday chat, short text rewriting |
| 16 GB | qwen3:8b or qwen3:14b | 5.2 GB / 9.3 GB | General Q&A, medium-difficulty writing |
| 24 GB or more | qwen3:30b (MoE) | About 18 GB | Long context, code, and reasoning tasks |
Tags and sizes change as the repository updates. Confirm them on the Ollama model library page or with ollama show <model-name> before you run anything.
On a 16 GB device running qwen3:14b, limit the context length to about 4K tokens. Long contexts are more likely to trigger memory swapping, which slows inference noticeably.
3. Full Deployment Workflow: Using Ollama as an Example
Ollama is an open-source tool for local inference. It runs on macOS, Windows, and Linux. It bundles model download, the inference engine, and a local HTTP service into one package, which makes it a good entry point.
3.1 Installing Ollama
On macOS, you can install the command-line version with Homebrew:
brew install ollamaollama serve
ollama serve runs the service in the foreground. For a background service, use the official macOS app. Windows users should download the installer from the official website. After installation, the service starts with the system. Linux users can follow the installation method in the official documentation. Before running any install script, read its contents and confirm they are safe.
After installation, check the version:
ollama --version
On Apple Silicon, Ollama uses the Metal backend for GPU acceleration. On Linux or Windows with an NVIDIA graphics card, install the matching graphics driver first.
3.2 Pulling and Running a Model
After choosing a size from the memory table above, run:
ollama pull qwen3:8bollama run qwen3:8b
pull downloads the model weights. The download ranges from a few GB to more than ten GB, so make sure you have enough disk space. Once the download finishes, run opens an interactive chat session. If you enter a question and get a response, the model can run inference normally.
Common issues and fixes:
- Interrupted download: run
ollama pullagain. Ollama resumes the chunks that were already downloaded. - Insufficient memory (for example,
model requires more system memory): switch to a smaller model size, or reduce the context length. - Very slow responses: usually caused by insufficient memory, which forces part of the computation to
