Files
nexus/wiki/concepts/本地AI推理.md

46 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: 本地AI推理
type: concept
tags: [AI, 本地部署, 推理]
sources: []
last_updated: 2026-04-16
---
## 定义
在自有硬件(本地服务器或 PC上运行 LLM 推理,而非调用云服务 API。
## 核心优势
- **数据隐私**:敏感数据不出本地网络
- **成本可控**:无 token 计费,硬件一次性投入
- **延迟可控**:内网延迟极低
- **离线可用**:不依赖外部网络
## 主流方案
| 方案 | 定位 | 最低配置 | GPU需求 |
|------|------|---------|---------|
| [[Ollama]] | 快速原型/轻量 | 4核CPU+8GB RAM | 可选 |
| [[vLLM]] | 高并发企业级 | 8核CPU+32GB RAM | 必须 |
| llama.cpp | 极致轻量 | 2核CPU+4GB RAM | 可选 |
## Ollama 部署路径
1. `curl -fsSL https://ollama.com/install.sh | sh`
2. `ollama pull qwen2.5-coder:7b`≈4.5GB
3. `ollama run qwen2.5-coder:7b`
## 远程 API 暴露
默认只监听 127.0.0.1,通过环境变量开放:
```
Environment="OLLAMA_HOST=0.0.0.0" # /etc/systemd/system/ollama.service
```
可被 [[n8n]]/[[OpenClaw]]/[[OpenWebUI]] 等工具远程调用。
## GPU 加速
- NVIDIA GPU + CUDA 环境下 Ollama 自动调度 GPU
- 无需额外配置,`nvidia-smi` 验证即可
## Connections
- [[本地AI推理]] ← 部署平台 ← [[Ollama]]
- [[本地AI推理]] ← 推荐模型 ← [[Qwen]]qwen2.5-coder:7b
- [[n8n]] ← 可调用 ← [[本地AI推理]](通过 HTTP Request Node