mac-mini-llm-lab – skill Khác cho agent AI
Cấu hình Mac mini thành máy chủ LLM cục bộ ổn định với truy cập từ xa, khả năng quan sát và vận hành an toàn khi mất điện. Dùng khi xây dựng máy chủ suy luận AI riêng tư chạy liên tục trên Apple Silicon.
Cài skill mac-mini-llm-lab bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/mac-mini-llm-lab-ed608.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /mac-mini-llm-lab – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/mac-mini-llm-lab-ed608.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $mac-mini-llm-lab – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/mac-mini-llm-lab-ed608.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /mac-mini-llm-lab – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/mac-mini-llm-lab-ed608.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /mac-mini-llm-lab – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
Mac mini LLM Lab
Turn a Mac mini into a low-noise, always-on local AI appliance.
When to Use This Skill
Use this skill when:
- Setting up a dedicated local LLM inference server
- Building a private AI development environment
- Need always-on model serving without cloud costs
- Running models that fit the actual machine’s unified memory
- Creating a home lab AI server for a small team
Prerequisites
- An actual Apple Silicon Mac mini configuration with sufficient available memory for the selected model
- macOS Sonoma 14+ or Sequoia 15+
- Ethernet connection (recommended over Wi-Fi)
- UPS for power protection (optional but recommended)
Host and exposure boundaries
Check actual model hardware/memory and installed macOS/tool support first. The throughput/RAM table is illustrative, not measured evidence or a fit guarantee; include KV cache/context/concurrency overhead. Keep Ollama loopback-only by default; TLS alone in the Caddy example does not add authentication. Configure an authenticated private proxy/tunnel and access policy before remote exposure. Loopback binding must be deliberately adapted for Docker access, without exposing an unauthenticated LAN listener. Approve persistent services, downloads, updates, reboots and FileVault/power changes separately as applicable; preserve existing settings and recovery access. Create script/log directories before writing them and do not run privileged diagnostics unattended from cron.
Initial System Setup
# Update macOS
softwareupdate --install --all
# Install Xcode command-line tools
xcode-select --install
# Install Homebrew
# Obtain the official Homebrew installer at a reviewed version, inspect it,
# and run the verified local file only after installation authorization.
# Core packages
brew install tmux htop btop wget jq git neovim
# Python environment (for MLX and custom scripts)
brew install [email protected] uv
# Monitoring
brew install prometheus node_exporterOllama Setup
# Install Ollama
brew install ollama
# Pull models based on your RAM
# 16GB Mac mini:
ollama pull llama3.1:8b
ollama pull nomic-embed-text
ollama pull codellama:7b
# 32GB Mac mini:
ollama pull llama3.1:8b
ollama pull qwen2.5:14b
ollama pull deepseek-coder-v2:16b
ollama pull nomic-embed-text
# 64GB+ Mac mini:
ollama pull llama3.1:70b
ollama pull qwen2.5:32b
ollama pull codellama:34b
# Verify Metal acceleration
ollama run llama3.1:8b --verbose
# Look for: "metal" in outputMLX Framework (Apple Silicon Native)
MLX runs models natively on Apple Silicon with excellent performance:
# Install MLX
uv pip install mlx mlx-lm
# Run a model
python3 -c "
from mlx_lm import load, generate
model, tokenizer = load('mlx-community/Llama-3.1-8B-Instruct-4bit')
response = generate(model, tokenizer, prompt='Explain Docker in 3 sentences', max_tokens=200)
print(response)
"
# MLX server (OpenAI-compatible API)
uv pip install mlx-lm[server]
mlx_lm.server --model mlx-community/Llama-3.1-8B-Instruct-4bit --port 8080Auto-Start with launchd
<!-- ~/Library/LaunchAgents/com.ollama.serve.plist -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.ollama.serve</string>
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/bin/ollama</string>
<string>serve</string>
</array>
<key>EnvironmentVariables</key>
<dict>
<key>OLLAMA_HOST</key>
<string>127.0.0.1:11434</string>
<key>OLLAMA_NUM_PARALLEL</key>
<string>4</string>
<key>OLLAMA_MAX_LOADED_MODELS</key>
<string>2</string>
<key>OLLAMA_FLASH_ATTENTION</key>
<string>1</string>
</dict>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/tmp/ollama.log</string>
<key>StandardErrorPath</key>
<string>/tmp/ollama.err</string>
</dict>
</plist># Load the service
launchctl load ~/Library/LaunchAgents/com.ollama.serve.plist
# Check status
launchctl list | grep ollama
# Unload if needed
launchctl unload ~/Library/LaunchAgents/com.ollama.serve.plistPower & Reliability
# Prevent idle sleep on this desktop (record existing values for rollback)
sudo pmset -a disablesleep 1
sudo pmset -a sleep 0
# Auto-restart after power failure
sudo pmset -a autorestart 1
# Schedule weekly reboot (Sunday 4 AM)
sudo pmset repeat shutdown U 03:55:00 poweron U 04:00:00
# Check power settings
pmset -gRemote Access
Tailscale (Recommended)
# Install Tailscale for easy secure remote access
brew install --cask tailscale
# Enable from menu bar, authenticate
# Access your Mac mini from anywhere: http://mac-mini:11434SSH Hardening
# Enable remote login
sudo systemsetup -setremotelogin on
# Edit SSH config
sudo nano /etc/ssh/sshd_config
# Add:
# PasswordAuthentication no
# PubkeyAuthentication yes
# PermitRootLogin no
# AllowUsers yourusername
# Restart SSH
sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
sudo launchctl load /System/Library/LaunchDaemons/ssh.plistReverse Proxy with Caddy
brew install caddy
# Caddyfile
cat > /opt/homebrew/etc/Caddyfile << 'EOF'
llm.local:443 {
tls internal
reverse_proxy localhost:11434
@api path /v1/*
handle @api {
reverse_proxy localhost:11434
}
}
webui.local:443 {
tls internal
reverse_proxy localhost:3000
}
EOF
brew services start caddyOpen WebUI Setup
# Run Open WebUI via Docker
docker run -d \
--name open-webui \
-p 3000:8080 \
-e OLLAMA_BASE_URL=http://host.docker.internal:11434 \
-e WEBUI_AUTH=true \
-v open-webui:/app/backend/data \
--restart unless-stopped \
ghcr.io/open-webui/open-webui:main
# Or install Docker first if not available
brew install --cask dockerMonitoring
# Health check script
cat > ~/scripts/llm-health.sh << 'SCRIPT'
#!/bin/bash
# Check Ollama
if curl -sf http://localhost:11434/api/tags > /dev/null; then
echo "$(date): Ollama OK"
curl -s http://localhost:11434/api/ps | python3 -m json.tool
else
echo "$(date): Ollama DOWN"
# Restart
launchctl kickstart -k gui/$(id -u)/com.ollama.serve
fi
# System stats
echo "CPU: $(top -l 1 -n 0 | grep 'CPU usage')"
echo "Memory: $(vm_stat | head -5)"
echo "Disk: $(df -h / | tail -1)"
echo "Thermal: $(sudo powermetrics --samplers smc -n 1 2>/dev/null | grep 'CPU die' || echo 'N/A')"
SCRIPT
chmod +x ~/scripts/llm-health.sh
# Schedule health check every 5 minutes
# Add to crontab: crontab -e
# */5 * * * * ~/scripts/llm-health.sh >> ~/logs/llm-health.log 2>&1Memory Usage by Model
| Model | RAM Required | Tokens/sec (M2) | Tokens/sec (M4) |
|-------|-------------|-----------------|-----------------|
| llama3.1:8b (Q4) | ~5 GB | ~25 t/s | ~45 t/s |
| qwen2.5:14b (Q4) | ~9 GB | ~15 t/s | ~30 t/s |
| llama3.1:70b (Q4) | ~40 GB | ~5 t/s | ~10 t/s |
| nomic-embed-text | ~300 MB | N/A | N/A |
| codellama:13b | ~8 GB | ~18 t/s | ~35 t/s |
Security Checklist
# Enable FileVault disk encryption
sudo fdesetup enable
# Enable firewall
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode on
# Disable unnecessary sharing services
sudo launchctl disable system/com.apple.screensharing
sudo launchctl disable system/com.apple.AirPlayXPCHelper
# Set strong admin password
# System Settings > Users & Groups
# Restrict Ollama to local network only (if not using Tailscale)
# Set OLLAMA_HOST=127.0.0.1 in launchd plistPerformance Tuning
# Increase file descriptor limits for concurrent requests
sudo launchctl limit maxfiles 65536 200000
# Check unified memory pressure
memory_pressure
# Monitor GPU usage (Metal)
sudo powermetrics --samplers gpu_power -n 1
# Optimize for inference (disable Spotlight indexing on model dirs)
mdutil -i off ~/.ollamaTroubleshooting
| Issue | Solution |
|-------|---------|
| Model loading slow | First load caches to memory; subsequent loads are fast |
| Out of memory | Use smaller quantization (Q4_K_M), reduce OLLAMA_MAX_LOADED_MODELS |
| Mac sleeping | Run sudo pmset -a disablesleep 1 |
| Ollama not starting | Check launchctl list | grep ollama, view /tmp/ollama.err |
| Slow over Wi-Fi | Use Ethernet; Wi-Fi adds latency to streaming responses |
| Thermal throttling | Ensure adequate ventilation, check powermetrics |
Related Skills
- ollama-stack (
ollama-stack) — Software stack with Docker Compose and LiteLLM - ssh-configuration (
ssh-configuration) — Secure remote access - vpn-setup (
vpn-setup) — Remote access via WireGuard/Tailscale
Limitations
- Infrastructure commands can disrupt services: confirm target host/scope and have backups/snapshots
… (nội dung đầy đủ có trong gói tải về)
Skill liên quan
- macos-spm-app-packaging – Khởi tạo, build, ký và đóng gói ứng dụng macOS SwiftPM mà không cần dự án Xcode.
- mailtrap-setting-up-sending-domain – Thêm hoặc xác minh sending domain của Mailtrap, khắc phục lỗi lan truyền DNS, thiết lập…
- makepad-basics – QUAN TRỌNG: Dùng cho bước đầu với Makepad và cấu trúc ứng dụng. Kích hoạt khi gặp…
- makepad-dsl – CRITICAL: Dùng cho cú pháp DSL và kế thừa của Makepad. Kích hoạt khi: makepad dsl…
- makepad-font – CRITICAL: Dùng cho font và hiển thị văn bản trong Makepad. Kích hoạt khi: makepad font…
- makepad-layout – CRITICAL: Dùng cho hệ thống bố cục (layout) của Makepad. Kích hoạt khi: makepad layout…
- makepad-reference – Hướng dẫn chẩn đoán lỗi build, widget, redraw và layout của Makepad theo đúng revision…
- makepad-shaders – CRITICAL: Dùng cho hệ thống shader của Makepad. Kích hoạt khi: makepad shader, makepad…