๐ 7 Ways to Run Any LLMs Locally - Simple Methods

A comprehensive guide to running Large Language Models (LLMs) locally on your machine using various tools and platforms.
๐ฌ Video Demonstration
1. ๐ฆ Ollama - The Dominant Local LLM Ecosystem
Ollama is the dominant ecosystem for running LLMs such as Llama 4, Mistral 3, and Gemma 3 locally. Additionally, multiple applications accept an Ollama integration, which makes it an excellent tool for faster and easier access to language models on our local machine.
Ollama now offers full OpenAI API compatibility, making it a drop-in replacement for OpenAI's cloud service. Recent features include function calling, structured JSON output, Flash Attention for vision models, and 30% faster inference on Apple Silicon and AMD GPUs.
๐ Resources
Ollama (+ OpenWebUI)
๐ฅ Deploy ANY Open-Source LLM with Ollama on Linux - 100% Local Solution: Watch Tutorial
๐ฅ Install Open Web-UI using Docker on Ubuntu: Watch Tutorial
๐ฅ Ollama with VSCode - AI Coding Assistant (Llama Copilot): Watch Tutorial
2. โก llama.cpp - High-Performance C++ Inference Engine
llama.cpp is a lightweight, high-performance inference engine written in C++ for running LLMs efficiently. It supports GGUF format models and offers hardware-optimized configurations for CPU, NVIDIA GPUs (CUDA), AMD GPUs (ROCm), and Moore Threads GPUs (MUSA).
๐ณ Hosting llama-server with Docker
Organizations using container-based deployments can leverage Docker images optimized for various hardware configurations. NVIDIA GPU acceleration requires the NVIDIA Container Toolkit.
llama.cpp supports GGUF file format models commonly hosted on Hugging Face Hugging Face.
๐ Quick Start with Docker
docker run -p 8080:8080 -v /path/to/models:/models --gpus all \
ghcr.io/ggml-org/llama.cpp:server-cuda -m models/phi-4.Q4_K_M.gguf \
--host 0.0.0.0 --port 8080 --n-gpu-layers 999
๐ Documentation
๐ llama.cpp GitHub
๐ Docker Guide
๐ง Docker Compose Example (CPU + GPU Hybrid Mode)
Note: The same compose file works with CPU only, CPU + GPU, or GPU only. Just change the image name and
GPU_LAYERSvariable:
0for CPU only
2for CPU + GPU hybrid
999for GPU only
Go on deploy path
cd /HDD2TB/iansari/deploy_llm/cuda
Create compose.yaml file
services:
llama:
image: ghcr.io/ggml-org/llama.cpp:full-cuda
container_name: llama
ports:
- "8000:8000"
volumes:
- ./models:/models
- ./entrypoint.sh:/entrypoint.sh
entrypoint: ["/entrypoint.sh"]
stdin_open: true
tty: true
# ๐ฅ GPU ENABLED | CPU + GPU HYBRID | GPU ONLY | Comment this if GPU not required.
runtime: nvidia
environment:
NVIDIA_VISIBLE_DEVICES: all
NVIDIA_DRIVER_CAPABILITIES: compute,utility
GPU_LAYERS: 2
CTX: 1024
PORT: 8000
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
๐ฎ Dedicated GPU Configuration
Docker containers can be configured to run llama-server on specific GPUs by GPU index:
- driver: nvidia
device_ids: ['0'] # Assign to GPU 0
capabilities: [gpu]
๐ Entrypoint Script
Note: Become Linux command line Expert Linux Commands for Cloud and DevOps
Create entrypoint.sh file
#!/usr/bin/env bash
set -e
# Enable it for debug | Keep the container running for debug | Get all information about commands.
# sleep infinity # <--- Debug enable it.
# docker exec -it llama /bin/bash
# ls -alsh /models
# ls -alsh /app
# ./llama-cli --help
# ./llama-server --help
#MODEL_PATH=${MODEL_PATH:-/models/llama-2-7b-chat.Q4_K_M.gguf}
MODEL_PATH=${MODEL_PATH:-/models/GLM-4.7-Flash-Q3_K_S.gguf}
PORT=${PORT:-8000}
THREADS=${THREADS:-$(nproc)}
CTX=${CTX:-1024}
GPU_LAYERS=${GPU_LAYERS:-0}
if [ ! -f "$MODEL_PATH" ]; then
echo "โ Model not found at $MODEL_PATH"
exit 1
fi
echo "๐ Starting llama.cpp server (CUDA)"
echo "๐ฆ Model: $MODEL_PATH"
echo "๐ง Context: $CTX"
echo "๐งต Threads: $THREADS"
echo "๐ฎ GPU layers: $GPU_LAYERS"
exec /app/llama-server \
-m "$MODEL_PATH" \
-c "$CTX" \
-t "$THREADS" \
-ngl "$GPU_LAYERS" \
--host 0.0.0.0 \
--port "$PORT"
๐ฅ Download Models (GGUF Format)
Download any Available Models an use it:
Download Example:
wget -P models \
https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGUF/resolve/main/llama-2-7b-chat.Q4_K_M.gguf
wget -P models \
https://huggingface.co/unsloth/GLM-4.7-Flash-GGUF/resolve/main/GLM-4.7-Flash-Q3_K_S.gguf
ls -alsh models
tree
.
โโโ compose.yaml
โโโ entrypoint.sh
โโโ models
โโโ GLM-4.7-Flash-Q3_K_S.gguf
โโโ llama-2-7b-chat.Q4_K_M.gguf
2 directories, 4 files
๐ Deployment Steps
chmod +x entrypoint.sh
docker compose up -d
โ Note: Docker Compose environment variables always override the entrypoint.sh script defaults.
Check variables:
docker exec -it llama env
docker exec -it llama env | grep GPU_LAYERS
๐งช Testing the API
List Models:
curl http://localhost:8000/v1/models | jq
Chat Completion:
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "local",
"messages": [
{"role": "user", "content": "Explain AI in simple words"}
]
}'
Check GPU usage using nvtop
apt update -y
apt install nvtop
nvtop
3. ๐ฅ๏ธ LM Studio - All-in-One Local LLM Workbench
LM Studio is an all-in-one desktop workbench for running LLMs locally with native fine-tuning support. It features multiple concurrent model loading, speculative decoding (1.5x-3x faster tokens), and document RAG integration for enhanced local AI workflows.
๐ Resources
๐ Official Website: lmstudio.ai
๐ GitHub Repository: lmstudio-ai
โจ Key Features
๐ฏ User-friendly GUI interface
๐ Multiple concurrent models
โก Speculative decoding for faster inference
๐ Document RAG integration
๐จ Native fine-tuning capabilities
4. ๐ vLLM - Production-Scale Inference Engine
vLLM is an open-source inference engine designed for running LLMs at production scale. Unlike Ollama or LM Studio, vLLM prioritizes throughput and latency optimization for multi-user scenarios, making it ideal for serving models in production environments.
๐ Resources
๐ Official Website: vllm.ai
๐ฆ GitHub Repository: vllm-project/vllm
๐ Quick Start
Installation:
python3.11 -m venv vllm_env
source vllm_env/bin/activate
pip install vllm
Start OpenAI-Compatible Server:
vllm serve meta-llama/Llama-2-7b-hf --port 8000 --gpu-memory-utilization 0.9
For 70B Models on Multiple GPUs:
vllm serve meta-llama/Llama-2-70b-hf --tensor-parallel-size 2 --port 8000
Batch Processing Example:
from vllm import LLM, SamplingParams
llm = LLM(model="meta-llama/Llama-2-7b-hf", dtype="bfloat16")
sampling_params = SamplingParams(temperature=0.8, max_tokens=256)
outputs = llm.generate(["Write hello world", "Explain AI"], sampling_params)
5. ๐จ Jan - Privacy-First ChatGPT Alternative
Jan is one of the most popular and aesthetically pleasing local LLM applications. It serves as a privacy-first alternative to ChatGPT, offering a beautiful user interface while keeping all your data local.
๐ Resources
๐ Official Website: jan.ai
๐ Desktop Documentation: jan.ai/docs/desktop
๐ฆ GitHub Repository: janhq/jan
โจ Key Features
๐ 100% privacy-focused
๐ Beautiful, modern UI
๐ฅ๏ธ Cross-platform desktop app
๐ฏ ChatGPT-like experience, locally
6. ๐ GPT4All - Free Open-Source LLM Ecosystem
GPT4All is a free, open-source ecosystem for running local LLMs. It includes a user-friendly desktop application, a comprehensive Python API, and a curated collection of models optimized for consumer-grade hardware.
๐ Resources
๐ Official Website: nomic.ai/gpt4all
๐ฆ GitHub Repository: nomic-ai/gpt4all
โจ Key Features
๐ฅ๏ธ Desktop application for Windows, macOS, and Linux
๐ Python API for integration
๐ป Optimized for consumer hardware
๐ Curated model collection
๐ Completely free and open-source
7. ๐ฆ llamafile - Single-Binary LLM Runtime
llamafile is a revolutionary single-file binary that packages an LLM with its complete runtime environment. This makes running models locally incredibly simpleโno complex dependencies, no installation hassles, just download and execute.
๐ Resources
๐ Official Website: llamafile.ai
๐ฆ GitHub Repository: mozilla-ai/llamafile
โจ Key Features
๐ฆ Single executable file
๐ง Zero installation required
๐ OpenAI-compatible API endpoints
๐ป Multi-architecture support
โก Quick start in minutes
๐ Quick Start
Download and run your first llamafile in minutes:
# Download an example model (LLaVA 1.5 7B)
curl -LO https://huggingface.co/Mozilla/llava-v1.5-7b-llamafile/resolve/main/llava-v1.5-7b-q4.llamafile
# Make it executable (macOS/Linux/BSD)
chmod +x llava-v1.5-7b-q4.llamafile
# Run it (opens browser automatically)
./llava-v1.5-7b-q4.llamafile
๐ฏ Conclusion
Each of these methods offers unique advantages for running LLMs locally. Choose based on your specific needs:
๐ฆ Ollama: Best for general use with broad ecosystem support
โก llama.cpp: Ideal for performance-critical deployments
๐ฅ๏ธ LM Studio: Perfect for users wanting a complete GUI workbench
๐ vLLM: Optimal for production-scale multi-user scenarios
๐จ Jan: Great for privacy-conscious users wanting a ChatGPT-like experience
๐ GPT4All: Excellent for beginners on consumer hardware
๐ฆ llamafile: Best for quick, no-installation deployments
๐ License
This guide is provided as-is for educational and professional use.
๐ค Contributing
Feel free to suggest improvements or report issues via pull requests or the issues tab.
๐ผ Connect with Me ๐๐
โญ If You Found This Helpful...
Please star the repo and share it! Thanks a lot! ๐
About the author
Hello! I'm a DevOps Engineer dedicated to continuous learning and contributing to the tech community. If you find value in what I share, feel free to spread the word to others who might benefit as well. Your support is greatly appreciated!
Comments
Join the discussionNo comments yet. Be the first to comment.



