Running Open-Source LLMs Locally: Hardware Selection and Setup Guide
Learn how to choose hardware for local LLM inference, install Ollama, download and run a model, monitor resource usage, and integrate function calling. This guide also covers troubleshooting, operating costs, licensing, and API security.
1. Choose Your Hardware Tier
When running a large language model locally, available memory—unified memory on Apple silicon or VRAM on a discrete GPU—determines which model sizes you can run. Open-source models are often released at 16-bit precision, resulting in large files. Quantization compresses model weights to around 4 bits, substantially reducing memory requirements with generally acceptable quality loss. This makes 4-bit quantized models a common starting point for personal devices.
The following reference specifications come from one model family. Memory figures are estimates for 4-bit quantized versions; check the relevant model page for actual requirements.
- Ultralight model, approximately 2.3 billion parameters: Around 4 GB of memory. Supports image and audio input with a 128K context window. Suitable for thin-and-light laptops; some phones and Raspberry Pi-class development boards can also run inference on-device.
- Lightweight model, approximately 4.5 billion parameters: Around 5.5 GB of memory. Supports image and audio input with a 128K context window. Suitable for everyday conversations and text processing on most entry-level and midrange computers.
- Mixture-of-experts (MoE) model: Approximately 25.2 billion total parameters, with about 3.8 billion activated per inference. Requires around 16–18 GB of memory and supports a 256K context window and image input, but not audio. Devices with 24 GB of memory can run it, with speeds approaching those of the lightweight model.
- Dense model, approximately 30.7 billion parameters: All parameters participate in every inference. Requires around 17–20 GB of memory. A 24 GB device may run it with little headroom, while a 32 GB device provides a smoother experience.
Treat these estimates as minimums. The operating system and other applications consume memory, and longer contexts increase cache requirements. As a rule of thumb, leave 3–4 GB of headroom. If memory is tight, choose a smaller model rather than forcing a larger one to run.
2. Install a Local Model Runtime
This guide uses Ollama, an open-source command-line tool that also provides a background service. It manages model downloads and exposes inference through an API. If you prefer a graphical interface, LM Studio is another common option with a similar workflow.
- macOS: Download the installer from the official website, drag the application into the Applications folder, and launch it. Apple silicon devices automatically use GPU acceleration.
- Windows: Download and run the installer from the official website. A system tray icon appears after installation.
- Linux: The official website provides an installation script. Download and inspect it before running:
curl -fsSL https://ollama.com/install.sh -o install.shless install.shsh install.sh
After installation, check the version:
ollama --version
If the command returns a version number, the installation was successful.
3. Download and Run a Model
Always use the exact model name and tag listed in the official model library. Do not infer a tag from the parameter count mentioned in an article.
The following example uses llama3.2:3b from the Ollama model library to demonstrate the command syntax:
ollama pull llama3.2:3bollama run llama3.2:3b
The pull command downloads the model files, typically several gigabytes to more than 10 GB. Make sure you have enough disk space before downloading. If a download is interrupted, running pull again can usually resume it.
The run command opens an interactive command-line chat. Ask a question. If the model produces a coherent response, local inference is working.
4. Monitor Resource Usage
Once the model is running, inspect its status with:
ollama ps
The output includes these fields:
- NAME: The model name.
- SIZE: The memory occupied by the loaded model.
- PROCESSOR: Whether the model is running on the CPU, GPU, or both, such as
100% GPUor14%/86% CPU/GPU. - UNTIL: How long the model will remain loaded in memory.
If PROCESSOR indicates that the model is running mostly on the CPU, it commonly means the model exceeds available GPU memory. Inference will be noticeably slower.
Try closing other memory-intensive applications, reducing the context length, or choosing a smaller model or a lower-bit quantized version.
5. Integrate Function Calling Through the API
Ollama serves requests at http://localhost:11434 by default. Its /api/chat endpoint accepts a tools parameter, allowing the model to decide whether to request a function you define.
Here is a weather-query example:
curl http://localhost:11434/api/chat -d '{"model": "llama3.2:3b","messages": [{"role": "user", "content": "What is the weather in Beijing right now?"}],"tools": [{"type": "function","function": {"name": "get_weather","description": "Get the weather for a specified city","parameters": {"type": "object","properties": {"city": {"type": "string"}},"required": ["city"]}}}],"stream": false}'
The model only returns a request specifying which function to call and what arguments to use. Your application executes the function.
Before execution, the application must validate arguments and check permissions. It then runs the function and returns the result to the model. Treat model output as untrusted input: never insert it directly into database queries or system commands.
In a hybrid architecture, the local model interprets requests and makes routing decisions. Your application calls cloud services—such as databases, object storage, and message queues—using its own credentials. Keep sensitive data local and send only necessary results to the cloud.
6. Understand Costs, Performance, and Compliance
- Costs: Spending on token-billed APIs may decrease, but hardware purchases, electricity, cooling, and maintenance time remain real costs.
- Performance: Local inference speed depends on your hardware. Large models and long inputs can take noticeably longer to respond than cloud APIs.
- Licensing: Permissive licenses generally allow commercial use, modification, and redistribution, but typically require retaining copyright notices and license files. Some models have additional usage terms. Read the original license before commercial use and consult legal counsel when necessary.
- Network exposure: Ollama listens only on the local machine by default. If you set
OLLAMA_HOSTto listen on0.0.0.0, protect the service with a firewall, reverse proxy, and authentication. Do not expose it directly to the public internet. - Benchmarks: Scores published by model providers or leaderboards often depend on specific test sets and prompting configurations. Review the original evaluation conditions and sources before citing numerical results.
7. Troubleshoot Common Issues
- Download fails: Check your network connection and run
pullagain. - Out-of-memory error during loading: Switch to a smaller model or a lower-bit quantized version.
- Responses are slow and
psshows substantial CPU use: The model may exceed available GPU memory. Apply the adjustments described in Section 4. - Another application cannot access the API: Confirm that the service is running, then check the local firewall and
OLLAMA_HOSTsettings. - Insufficient disk space: Run
ollama listto view downloaded models. Useollama rm MODEL_NAMEto remove models you no longer need. Before deleting one, confirm that none of your applications depend on it. - Before changing configuration: Back up configuration files, important prompts, and application data.
8. Conclusion
Start with the smallest model that meets your quality requirements. Use ollama ps to verify that it is running on the GPU, then integrate function calling.
Before deployment, review the model’s license terms and confirm that the API is not exposed to an uncontrolled network.
