ollama-stack – skill Khác cho agent AI
Chạy khối lượng công việc LLM cục bộ với Ollama, Open WebUI và tinh chỉnh theo GPU cho môi trường phát triển riêng tư.
Cài skill ollama-stack 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/ollama-stack-cf703.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /ollama-stack – 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/ollama-stack-cf703.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $ollama-stack – 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/ollama-stack-cf703.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /ollama-stack – 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/ollama-stack-cf703.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /ollama-stack – 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.
Ollama Stack
Deploy a local LLM stack for offline and privacy-first workflows.
When to Use This Skill
Use this skill when:
- Setting up private/local LLM inference for development
- Building air-gapped AI environments
- Running models on personal hardware (Mac, Linux, Windows with GPU)
- Creating team-shared inference endpoints
- Prototyping before committing to cloud LLM APIs
Deployment boundaries
Pin reviewed container images and model revisions before use; table sizes/VRAM are illustrative and context/concurrency change requirements. A local endpoint does not guarantee offline operation: model downloads, WebUI features and proxy backends can make network calls. Confirm mounted data, authentication and network policy; the nginx IP restriction below is not user authentication. Container OLLAMA_HOST=0.0.0.0 is for the private Compose network while published host ports bind to loopback. See [Ollama networking guidance](https://docs.ollama.com/faq).
Prerequisites
- 8 GB+ RAM (16 GB+ recommended for 7B+ models)
- For GPU acceleration: NVIDIA GPU with 6 GB+ VRAM, or Apple Silicon Mac
- Docker (for containerized deployment)
- 20 GB+ disk for model storage
Quick Start
# Install Ollama
# Download to a private review directory; inspect the exact script before any authorized execution.
# Follow the platform-specific official installation method; do not execute a moving installer blindly.
# Start the server
ollama serve
# Pull and run a model
ollama pull llama3.1:8b
ollama run llama3.1:8b "Explain Kubernetes pods in one paragraph"
# List available models
ollama list
# Pull specific quantization
ollama pull llama3.1:8b-instruct-q4_K_MModel Selection Guide
| Model | Size | VRAM | Best For |
|-------|------|------|----------|
| llama3.1:8b | 4.7 GB | 6 GB | General chat, coding |
| llama3.1:70b | 40 GB | 48 GB | Complex reasoning |
| codellama:13b | 7.4 GB | 10 GB | Code generation |
| mistral:7b | 4.1 GB | 6 GB | Fast general tasks |
| mixtral:8x7b | 26 GB | 32 GB | High-quality MoE |
| nomic-embed-text | 274 MB | 1 GB | Embeddings for RAG |
| llava:13b | 8 GB | 10 GB | Vision + text |
| deepseek-coder-v2:16b | 9 GB | 12 GB | Code generation |
| qwen2.5:14b | 9 GB | 12 GB | Multilingual, reasoning |
Docker Compose — Full Stack
# docker-compose.yml
services:
ollama:
image: ollama/ollama:latest
container_name: ollama
restart: unless-stopped
ports:
- "127.0.0.1:11434:11434"
volumes:
- ollama_data:/root/.ollama
environment:
- OLLAMA_HOST=0.0.0.0
- OLLAMA_NUM_PARALLEL=4
- OLLAMA_MAX_LOADED_MODELS=2
- OLLAMA_FLASH_ATTENTION=1
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:11434/api/tags"]
interval: 30s
timeout: 10s
retries: 3
open-webui:
image: ghcr.io/open-webui/open-webui:main
container_name: open-webui
restart: unless-stopped
ports:
- "127.0.0.1:3000:8080"
volumes:
- webui_data:/app/backend/data
environment:
- OLLAMA_BASE_URL=http://ollama:11434
- WEBUI_AUTH=true
- WEBUI_SECRET_KEY=${WEBUI_SECRET_KEY:?supply a private generated secret}
- DEFAULT_MODELS=llama3.1:8b
depends_on:
ollama:
condition: service_healthy
litellm:
image: ghcr.io/berriai/litellm:main-latest
container_name: litellm
restart: unless-stopped
ports:
- "127.0.0.1:4000:4000"
volumes:
- ./litellm-config.yaml:/app/config.yaml
command: ["--config", "/app/config.yaml"]
depends_on:
ollama:
condition: service_healthy
volumes:
ollama_data:
webui_data:LiteLLM Proxy Config
# litellm-config.yaml
model_list:
- model_name: llama3
litellm_params:
model: ollama/llama3.1:8b
api_base: http://ollama:11434
- model_name: codellama
litellm_params:
model: ollama/codellama:13b
api_base: http://ollama:11434
- model_name: embeddings
litellm_params:
model: ollama/nomic-embed-text
api_base: http://ollama:11434
general_settings:
master_key: os.environ/LITELLM_MASTER_KEY # supply privately; verify syntax for pinned LiteLLM version
# Configure and verify a finite budget separately; zero semantics vary by version.API Usage
Ollama exposes an OpenAI-compatible API:
# Chat completion
curl http://localhost:11434/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "llama3.1:8b",
"messages": [{"role": "user", "content": "Hello"}],
"stream": false
}'
# Embeddings
curl http://localhost:11434/v1/embeddings \
-H "Content-Type: application/json" \
-d '{
"model": "nomic-embed-text",
"input": "The quick brown fox"
}'
# List models
curl http://localhost:11434/api/tagsPython Client
# pip install ollama
import ollama
# Chat
response = ollama.chat(
model="llama3.1:8b",
messages=[{"role": "user", "content": "Explain Docker in 3 sentences"}],
)
print(response["message"]["content"])
# Streaming
for chunk in ollama.chat(
model="llama3.1:8b",
messages=[{"role": "user", "content": "Write a haiku about containers"}],
stream=True,
):
print(chunk["message"]["content"], end="", flush=True)
# Embeddings
result = ollama.embed(model="nomic-embed-text", input="Hello world")
print(f"Embedding dimensions: {len(result['embeddings'][0])}")OpenAI SDK Compatibility
import os
from openai import OpenAI
# Configure OLLAMA_CLIENT_KEY privately for this endpoint. Local unauthenticated
# Ollama ignores the SDK-required value; it is not access control.
client = OpenAI(base_url="http://localhost:11434/v1", api_key=os.environ["OLLAMA_CLIENT_KEY"])
response = client.chat.completions.create(
model="llama3.1:8b",
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)Custom Modelfiles
Create specialized models with custom system prompts and parameters:
# Modelfile.devops-assistant
FROM llama3.1:8b
SYSTEM """You are a DevOps expert assistant. You provide concise, production-ready
advice about infrastructure, CI/CD, containers, and cloud services.
Always include relevant commands and config examples."""
PARAMETER temperature 0.3
PARAMETER top_p 0.9
PARAMETER num_ctx 8192
PARAMETER repeat_penalty 1.1# Build and use custom model
ollama create devops-assistant -f Modelfile.devops-assistant
ollama run devops-assistant "Set up a GitHub Actions workflow for Docker builds"GPU Configuration
NVIDIA
# Verify GPU access
nvidia-smi
ollama run llama3.1:8b --verbose # Shows GPU layers loaded
# Environment tuning
export OLLAMA_NUM_PARALLEL=4 # Concurrent requests
export OLLAMA_MAX_LOADED_MODELS=2 # Models in VRAM
export OLLAMA_FLASH_ATTENTION=1 # Faster attention
export CUDA_VISIBLE_DEVICES=0,1 # Multi-GPUApple Silicon
# Metal acceleration is automatic on macOS
# Verify with:
ollama run llama3.1:8b --verbose
# Look for: "metal" in the output
# Optimize for unified memory
export OLLAMA_NUM_PARALLEL=2 # Keep memory headroom
export OLLAMA_MAX_LOADED_MODELS=1 # One model at a time on 16GBMonitoring
# Check running models and memory usage
curl http://localhost:11434/api/ps
# Prometheus metrics (if enabled)
curl http://localhost:11434/metrics
# Quick health check script
#!/bin/bash
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:11434/api/tags)
if [ "$response" = "200" ]; then
echo "Ollama is healthy"
curl -s http://localhost:11434/api/ps | python3 -m json.tool
else
echo "Ollama is down (HTTP $response)"
exit 1
fiSystemd Service
# /etc/systemd/system/ollama.service
[Unit]
Description=Ollama LLM Server
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=/usr/local/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
Environment="OLLAMA_HOST=127.0.0.1:11434"
Environment="OLLAMA_NUM_PARALLEL=4"
Environment="OLLAMA_FLASH_ATTENTION=1"
LimitNOFILE=65535
[Install]
WantedBy=default.targetsudo useradd -r -s /bin/false -m -d /usr/share/ollama ollama
sudo systemctl daemon-reload
sudo systemctl enable --now ollama
sudo systemctl status ollamaSecurity
- Bind to
127.0.0.1in production (default), use reverse proxy for remote access - Set
WEBUI_AUTH=trueon Open WebUI - Use nginx with TLS for remote access:
server {
listen 443 ssl;
server_name llm.internal.example.com;
ssl_certificate /etc/ssl/certs/llm.pem;
ssl_certificate_key /etc/ssl/private/llm.key;
location / {
proxy_pass http://127.0.0.1:11434;
proxy_set_header Host $host;
proxy_buffe… (nội dung đầy đủ có trong gói tải về)
Skill liên quan
- on-call-handoff-patterns – Các mẫu hiệu quả khi bàn giao ca trực on-call, đảm bảo tính liên tục, truyền ngữ cảnh và…
- onboarding-playbook – Checklist onboarding: bước, giai đoạn và thứ tự, phòng ban, người phụ trách, SOP liên…
- oneroster-csv-validator – Kiểm tra bộ CSV danh sách lớp OneRoster v1.1 và v1.2 của 1EdTech / IMS Global: tính toàn…
- options-flow-analyzer – So sánh tỷ lệ put/call của options thô và options đã lọc rõ ràng, kèm các giả định đã…
- oral-health-analyzer – Phân tích dữ liệu sức khỏe răng miệng, nhận diện các dạng vấn đề răng miệng, đánh giá…
- osint-methodology – Phương pháp OSINT toàn diện cho các hoạt động red-team bên ngoài và đánh giá bề mặt tấn…
- oss-hunter – Tự động tìm kiếm các cơ hội đóng góp OSS có tác động cao trong các repository đang thịnh…
- page-speed-score-simulator – Page Speed Score Simulator. Dùng khi làm việc với báo cáo hiệu năng hoặc các đầu vào…