Running a 3B LLM Locally with Ollama: A Practical Setup Guide
As large language models evolve, the trade-off between parameter count and inference efficiency has drawn increasing attention. 3B (3-billion-parameter) models offer fast inference and low resource usage, making them well suited for personal workstations. This guide uses Ollama to walk through hardware estimation, installation, IDE integration, and performance tuning for local 3B model deployment. Most figures are reference values—actual results depend on your hardware and configuration.
Why Deploy Models Locally?
- Data never leaves your machine: Prompts, code snippets, and model outputs are all processed locally. This matters most when working with proprietary code or client data.
- Predictable costs: Hardware is a one-time investment. With heavy usage, you don’t need to worry about token-based billing growing with your workload.
- No dependency on public internet: Local inference eliminates network round trips. Actual latency still depends on GPU performance, model size, and context length—there’s no fixed number.
- Works offline: The model keeps serving even without a network connection or on an isolated intranet.
- Rich tunable options: You can set context length, sampling temperature, and quantization precision yourself to fit specific tasks.
Hardware Requirements and Estimation
Before deploying, estimate VRAM and memory needs. Model weight size depends on parameter count and quantization precision. Approximate weight sizes for a 3B model:
| Precision | Weight Size (approx.) | Notes |
|---|---|---|
| FP16 | 6 GB | Highest precision, but leaves almost no headroom on 6GB VRAM |
| INT8 | 3 GB | Minor precision loss; suits devices with ~12GB VRAM |
| INT4 (Q4_K_M) | 2 GB | Smallest footprint; Ollama’s default 3b tag uses this, and fits fully in 6GB VRAM |
Actual usage also includes the KV cache (which grows with context length) and runtime overhead. Expanding context from 4K to 32K significantly increases cache usage. Therefore, 6GB VRAM works for an INT4 3B model with context kept under 8K. For FP16, plan for at least 12GB VRAM.
Minimum configuration reference
- CPU: A mainstream processor with 6 cores/12 threads or better. Without a discrete GPU, the model can run purely on CPU, but noticeably slower.
- RAM: 16GB. Memory pressure can be significant when running multiple applications.
- GPU: 6GB VRAM for an INT4 quantized model.
- Storage: Reserve 20GB+. The model file is about 2GB, but the tool itself and caches also need space. An SSD shortens load times.
Recommended configuration reference
12GB VRAM and 32GB RAM. This leaves headroom for longer contexts, or switching to larger models when needed.
Deployment Steps
Step 1: Install Ollama
Ollama is an open-source tool for running models locally, supporting Windows, macOS, and Linux. Download the installer for your system from the official site, ollama.com. Linux users can also run the official install script:
curl -fsSL https://ollama.com/install.sh | sh
Before executing a remote script, open the URL in a browser and review its contents first. This reduces the risk of running a tampered script.
Step 2: Verify the Installation
Open a terminal and run:
ollama --version
A version number confirms a successful install. If you see command not found, reopen the terminal, or check that the install directory is in your system PATH.
Step 3: Pull and Run a Model
This guide uses Llama 3.2 3B as an example:
ollama run llama3.2:3b
The first run downloads roughly 2GB of model files. Once complete, the terminal enters interactive mode—type questions to chat, and type /bye to exit.
Before running, read the model’s license to confirm your intended use (such as commercial use) is permitted. License terms vary considerably between models.
After downloading, verify the model is ready:
ollama list
To call the model programmatically, use the local API at its default address, http://localhost:11434:
curl http://localhost:11434/api/generate -d '{"model":"llama3.2:3b","prompt":"Introduce yourself in one sentence","stream":false}'
Quoting rules differ in Windows PowerShell, so you can use Invoke-RestMethod to send the same request instead.
Step 4: Integrate with a Code Editor
Ollama provides an OpenAI-compatible API. Using the Continue extension in VS Code as an example, add the following to your configuration file:
models:- name: Local 3B modelprovider: ollamamodel: llama3.2:3bapiBase: http://localhost:11434
Field names should follow the extension’s documentation for your version. If your network uses a proxy, add localhost and 127.0.0.1 to NO_PROXY; otherwise, requests may be routed to the external proxy and fail. The first model load is slow, so consider increasing the timeout in the extension settings.
Performance Measurement and Tuning
Ollama can output speed statistics at runtime with the --verbose flag:
ollama run llama3.2:3b --verbose
The eval rate at the end of the output shows tokens generated per second. As a reference, on a mid-range GPU with INT4 quantization and a 4096 context, generation speed may fall in the 40–50 tokens/s range, with first load taking around 15–20 seconds. These are example ranges only—not guarantees across all devices. A different GPU, quantization, or a longer prompt will change the results. Always rely on your own --verbose output.
The main factors affecting speed:
- Whether the model runs entirely on GPU. Run
ollama psand check the PROCESSOR column.100% GPUmeans it’s fully on the graphics card. If you see a CPU/GPU split, some layers have been offloaded to system memory and speed will drop. - Quantization precision. INT4 uses less memory and runs faster, but output quality is usually slightly lower than INT8 or FP16. For code completion and everyday Q&A, INT4 is generally sufficient. When you need higher precision, pull the corresponding tag, such as
llama3.2:3b-instruct-fp16—check the model page for exact tag names. - Context length. Longer contexts mean larger caches and slower speeds. In interactive mode, adjust with
/set parameter num_ctx 4096. To persist the setting, addPARAMETER num_ctx 4096to a Modelfile. - Concurrency and keep-alive time. The environment variable
OLLAMA_NUM_PARALLELcontrols parallel requests per model—higher concurrency means higher VRAM usage.OLLAMA_KEEP_ALIVEdetermines how long the model stays in memory after going idle.
Storage path: The default model directory is on the system drive. If space is tight, set the OLLAMA_MODELS environment variable to a directory on a data drive, then restart the Ollama service. On Windows, set it in System Environment Variables; on macOS and Linux, add it to your shell profile or service configuration.
Drivers: Keep your GPU driver on a recent stable version. With outdated drivers, Ollama may fail to use GPU acceleration.
Troubleshooting Common Issues
- Out of VRAM or memory. First run
ollama psto check model usage. Options include loweringnum_ctx, switching to a smaller quantization, or closing other programs using VRAM. If part of the model runs on CPU, it usually still works, just slower. - Port already in use. Ollama uses port 11434 by default. On Windows, run
netstat -ano | findstr 11434to find the conflicting process; on macOS and Linux, runlsof -i :11434. If there’s a genuine conflict, setOLLAMA_HOST=127.0.0.1:11435and restart the service, then update the address in your editor extension accordingly. - Interrupted model download. Rerun
ollama pull—already downloaded data is typically reused. If it keeps failing, check your network and disk space. - Poor output in non-English languages. Specify the role, language, and format explicitly in your prompt, for example: “Answer in simplified Chinese and include code comments.” For specialized terminology, providing a glossary or examples usually works better than simply adding more instructions.
- Editor can’t connect. First confirm
ollama listshows the model, then test API reachability with curl. If both work, check that the extension’s address islocalhost:11434and that proxy settings aren’t interfering with local requests.
Security and Compliance Notes
- Download installers and models only from official sources. If the publisher provides checksums, verify them after downloading.
- Keep the service bound to localhost only. Ollama binds to 127.0.0.1 by default. Don’t change
OLLAMA_HOSTto0.0.0.0and expose it directly to a LAN or the public internet—anyone who can reach that address could call your model. If LAN access is genuinely needed, pair it with firewall rules and authentication. - Check the model license. Confirm permitted use, commercial restrictions, and redistribution requirements.
- Mind local data. Model files and runtime logs are stored on your local disk. On shared machines, configure account permissions appropriately.
Conclusion
A workstation with 16GB RAM and 6GB VRAM is enough to run a 3B model locally. The key is estimating VRAM first, choosing the right quantization, then verifying actual performance with --verbose and ollama ps. Once you’ve mastered these steps, you can integrate the model into your daily development workflow while keeping your data on your own device.
