This tutorial walks you through setting up BenchRig, validating your platform hardware acceleration (macOS Apple Silicon Metal or Linux/WSL2 NVIDIA CUDA), and executing your first local LLM benchmark.
Before beginning, ensure you have:
- Python 3.10+ installed:
python3 --version
- Ollama installed and running:
- macOS: Install via ollama.com or
brew install ollama. - Linux / WSL2: Install via
curl -fsSL https://ollama.com/install.sh | sh. - Verify daemon status:
curl -s http://localhost:11434/api/tags
- macOS: Install via ollama.com or
- (Optional) Microsoft Foundry Local installed:
- Verify CLI:
foundry --version - Verify server daemon:
foundry server status
- Verify CLI:
Install the published package from PyPI in a virtual environment using Python 3.10+. These commands work on macOS Apple Silicon and Linux/WSL2:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install benchrigOptional extras use that same environment:
python -m pip install "benchrig[charts]" # PNG chart export
python -m pip install "benchrig[onnx-gpu]" # direct ONNX Runtime GenAI on NVIDIA CUDASee the runtime guide for Ollama, Foundry Local, direct ONNX and Prism setup.
Use Python 3.11+ for the development dependencies. This requirement applies to development tools; the published BenchRig package supports Python 3.10+.
git clone https://github.com/senssei/benchrig.git
cd benchrig
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -e ".[dev]"See the developer guide for checks and contribution workflow.
Execute the non-destructive diagnostic check to verify accelerator detection and daemon reachability:
benchrig --check- macOS: Displays Apple Silicon GPU core count (e.g. M2/M3/M4 Max), Unified Memory (UMA) size, Metal driver version, and Ollama Metal VRAM buffer allocations.
- Linux / WSL2: Displays NVIDIA GeForce RTX model, dedicated VRAM capacity, driver version, CUDA UMD version, and system host RAM.
- Runtimes: Validates whether Ollama (
http://localhost:11434) and Microsoft Foundry Local (http://127.0.0.1:<port>) are responding.
Pull the standard benchmark models configured in config.yaml:
# Pull standard Ollama coding & reasoning models:
benchrig --runtime ollama --pull-recommendedOr manually pull your preferred model:
ollama pull qwen2.5-coder:7b
ollama pull phi3:miniEvaluate raw token throughput (tokens/s) and Time to First Token (TTFT):
benchrig --runtime ollama --models qwen2.5-coder:7b --suite speedEvaluate real-world code generation precision against deterministic unit test assertions in isolated subshells:
benchrig --runtime ollama --models qwen2.5-coder:7b --suite codingDuring execution, BenchRig:
- Prompts the model with algorithmic challenges (e.g., Nested Dict Flattening, LRU Cache, Valid Parentheses).
- Extracts clean Python code blocks.
- Spawns an isolated subprocess to execute the code against rigorous unit tests.
- Reports pass/fail status, execution time, and memory consumption.
Upon completion, BenchRig generates:
- Interactive Rich Terminal Leaderboard: Shows rankings, composite scores, decode speeds, TTFT, and cloud API cost savings.
results/LATEST_SUMMARY.md: Human-readable Markdown summary with assertion breakdowns.results/runs/benchmark_<timestamp>.json: Machine-readable telemetry and scores.
To display the latest run results in the terminal at any time:
benchrig --compare results/latest.jsonThe same commands work on other runtimes: --runtime foundry, --runtime onnx-gpu and --runtime prism (a
Prism server started with prism serve). benchrig --check shows which are reachable;
see Runtimes for setup and model prefixes.
- Learn how to enable GPU acceleration in Microsoft Foundry Local: Tutorial 2: Foundry GPU Setup.
- Run side-by-side cross-engine comparisons: Tutorial 3: Cross-Engine Benchmarking.
- Offload agent coding routines with zero token cost: see local-coders.