<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[单卡 AMD Radeon AI Pro R9700 (32GB) + Qwen3.6-27B + Hermes Agent 本地部署经验+LLM公网部署]]></title><description><![CDATA[<h2>硬件配置</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>部件</th>
<th>型号</th>
<th>参数</th>
</tr>
</thead>
<tbody>
<tr>
<td>CPU</td>
<td>Intel Core i7-7700K</td>
<td>4核8线程 @ 4.2GHz</td>
</tr>
<tr>
<td>GPU</td>
<td><strong>AMD Radeon AI Pro R9700 × 1</strong></td>
<td>32GB VRAM, gfx1201, ROCm</td>
</tr>
<tr>
<td>内存</td>
<td>DDR4</td>
<td>32GB</td>
</tr>
<tr>
<td>存储</td>
<td>NVMe SSD</td>
<td>937GB (可用 ~630GB)</td>
</tr>
<tr>
<td>OS</td>
<td>Ubuntu 24.04.4 LTS</td>
<td>内核 6.19.14</td>
</tr>
</tbody>
</table>
<h2>软件栈</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>组件</th>
<th>版本/说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>ROCm</td>
<td>7.8.0 (rocm-smi 4.0.0)</td>
</tr>
<tr>
<td>llama.cpp</td>
<td>b4672 (自编译, GCC 13.3.0)</td>
</tr>
<tr>
<td>Hermes Agent</td>
<td>Nous Research 最新版</td>
</tr>
<tr>
<td>模型</td>
<td>Qwen3.6-27B-Q4_K_M.gguf (17.1GB)</td>
</tr>
<tr>
<td>上下文</td>
<td>128K tokens (131072)</td>
</tr>
</tbody>
</table>
<h2>llama-server 启动参数详解</h2>
<pre><code>#!/bin/bash
exec /home/lw/llama.cpp/build/bin/llama-server \
  -m /home/lw/models/Qwen3.6-27B-Q4_K_M.gguf \
  --host 0.0.0.0 --port 8080 \
  --n-gpu-layers 999 \
  -c 131072 \
  --cache-type-k q8_0 \
  --cache-type-v q8_0 \
  --mlock \
  --timeout 120 \
  --defrag-thold 0.1 \
  --no-cache-prompt \
  --cache-ram 0 \
  --reasoning off
</code></pre>
<h3>参数说明</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>参数</th>
<th>作用</th>
<th>为什么这么设</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>-ngl 999</code></td>
<td>全部层卸载到 GPU</td>
<td>R9700 32GB 足够放下 Q4_K_M 的 27B 模型</td>
</tr>
<tr>
<td><code>-c 131072</code></td>
<td>上下文 128K</td>
<td>日常够用；256K 下 R9700 预填充太慢</td>
</tr>
<tr>
<td><code>--cache-type-k/v q8_0</code></td>
<td>KV cache 用 q8_0 精度</td>
<td>比默认 f16 <strong>省一半 KV cache 显存</strong>，质量损失极小</td>
</tr>
<tr>
<td><code>--mlock</code></td>
<td>锁定内存防 swap</td>
<td>单卡显存 32GB 接近满载时，防止系统把模型 swap 到硬盘</td>
</tr>
<tr>
<td><code>--cache-ram 0</code></td>
<td>禁用 CPU RAM 缓存</td>
<td>避免跨请求 prompt cache 触发崩溃</td>
</tr>
<tr>
<td><code>--no-cache-prompt</code></td>
<td>禁用 prompt 缓存</td>
<td>同上，防崩</td>
</tr>
<tr>
<td><code>--defrag-thold 0.1</code></td>
<td>KV 缓存碎片整理</td>
<td>长时间运行时显存碎片化会降低性能</td>
</tr>
<tr>
<td><code>--reasoning off</code></td>
<td>关闭 thinking 输出</td>
<td>Claude Code 不需要 thinking 内容，省带宽</td>
</tr>
<tr>
<td><code>--timeout 120</code></td>
<td>请求超时 120 秒</td>
<td>匹配 Claude Code 超时设置</td>
</tr>
</tbody>
</table>
<h2>性能基准</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>场景</th>
<th>耗时</th>
<th>计算</th>
</tr>
</thead>
<tbody>
<tr>
<td>短对话 (24 tok 输入 + 2 tok 输出)</td>
<td><strong>0.63 秒</strong></td>
<td>几乎瞬时响应</td>
</tr>
<tr>
<td>长文处理 (1133 tok 输入 + 50 tok 输出)</td>
<td><strong>8.16 秒</strong></td>
<td>适合日常编程对话</td>
</tr>
<tr>
<td><strong>Prefill 速度</strong></td>
<td><strong>~186 tok/s</strong></td>
<td></td>
</tr>
<tr>
<td><strong>Decode 速度</strong></td>
<td>~24 tok/s</td>
<td>正常单卡水平</td>
</tr>
<tr>
<td>VRAM 占用</td>
<td><strong>23.2/34.2 GB (68%)</strong></td>
<td>还有余量，不 OOM</td>
</tr>
</tbody>
</table>
<blockquote>
<p dir="auto">关键对比：双 R9700 用户因 PCIe 跨卡通信瓶颈，Prefill 仅 ~21 tok/s。<strong>单卡反而快 9 倍！</strong></p>
</blockquote>
<h2>与 Hermes Agent 配合</h2>
<p dir="auto">在 <code>~/.hermes/config.yaml</code> 中配置：</p>
<pre><code class="language-yaml">model:
  default: Qwen3.6-27B-Q4_K_M.gguf
  provider: ubuntu-llm
  base_url: http://192.168.8.195:8080/v1
  api_key: llm_G4eXme-...
  api_mode: chat_completions
</code></pre>
<p dir="auto"><code>llama-server</code> 原生支持 OpenAI API（<code>/v1/chat/completions</code>），所以任何兼容 OpenAI 的客户端都能直连。</p>
<h2>跨机器调用</h2>
<h3>Windows Claude Code 直连（无需代理）</h3>
<p dir="auto">新版 Claude Code 原生支持 Anthropic API，而 <code>llama-server</code> 也原生实现了 <code>/v1/messages</code> 端点，<strong>不需要中间代理</strong>：</p>
<pre><code class="language-cmd">setx ANTHROPIC_BASE_URL http://192.168.8.195:8080
claude --dangerously-skip-permissions
</code></pre>
<p dir="auto">注意：不要加 <code>/v1</code> 后缀！Claude Code 会自动拼接 <code>/v1/messages</code>，写全路径会变成 <code>/v1/v1/messages</code> 报 400。</p>
<h3>MacMini Hermes Agent / OpenClaw 配置</h3>
<pre><code class="language-yaml">model:
  base_url: http://192.168.8.195:8080/v1
  api_mode: chat_completions
</code></pre>
<pre><code>OpenClaw (client)  →  llama-server on Ubuntu (192.168.8.195:8080)
</code></pre>
<h3>性能对比：直连 vs 代理</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>方式</th>
<th>延迟</th>
<th>维护</th>
<th>推荐</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>ANTHROPIC_BASE_URL</code> 直连</td>
<td>最低</td>
<td>无需额外进程</td>
<td>优先</td>
</tr>
<tr>
<td>OpenAI 兼容代理（中间人）</td>
<td>多一次转换</td>
<td>加个进程要维护</td>
<td>仅当直连不可用时</td>
</tr>
</tbody>
</table>
<h2>工具脚本</h2>
<h3>模型切换: <code>~/swap-model.sh</code></h3>
<pre><code class="language-bash">./swap-model.sh qwen    # 切换到 Qwen3.6
./swap-model.sh gemma   # 切换到 Gemma-4
</code></pre>
<h3>systemd 开机自启: <code>~/.config/systemd/user/qwen-server.service</code></h3>
<pre><code class="language-ini">[Unit]
Description=Qwen3.6-27B LLM Server
After=network-online.target

[Service]
Type=simple
ExecStart=/usr/bin/sg render -c '/bin/bash /home/lw/run_qwen.sh'
WorkingDirectory=/home/lw/models
Restart=on-failure
RestartSec=10

[Install]
WantedBy=default.target
</code></pre>
<pre><code class="language-bash">systemctl --user enable qwen-server.service  # 开机自启
systemctl --user start qwen-server.service    # 立即启动
</code></pre>
<h3>Hermes Agent cron 保姆监控</h3>
<p dir="auto">每分钟自动检查 llama-server 健康状态，挂了自动重启：</p>
<pre><code class="language-bash">hermes cron create \
  --name "llama-server watchdog" \
  --schedule "every 5m" \
  --prompt "Check if llama-server is running on localhost:8080. If down, restart it with ~/run_qwen.sh." \
  --deliver local \
  --toolsets terminal
</code></pre>
<h2>公网部署注意事项</h2>
<p dir="auto">如果想把内网的 llama-server 暴露到公网使用，需要注意以下几点：</p>
<h3>安全第一</h3>
<p dir="auto"><strong>绝对不要</strong>把 llama-server 直接暴露在公网！llama-server 本身没有认证机制，直接暴露等于把你的 32GB 显存和 100% GPU 让全网随意调用。</p>
<p dir="auto">推荐方案：用 <strong>Cloudflare Tunnel</strong>（cloudflared）做安全穿透：</p>
<pre><code class="language-bash"># 安装 cloudflared
wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -O /usr/local/bin/cloudflared
chmod +x /usr/local/bin/cloudflared

# 创建 tunnel
cloudflared tunnel create my-llm-tunnel

# 配置 DNS
cloudflared tunnel route dns my-llm-tunnel your-domain.com

# 创建配置文件 ~/.cloudflared/config.yml
</code></pre>
<p dir="auto">配置示例：</p>
<pre><code class="language-yaml">tunnel: &lt;tunnel-id&gt;
credentials-file: /root/.cloudflared/&lt;tunnel-id&gt;.json

ingress:
  - hostname: llm.your-domain.com
    service: http://localhost:8080
  - service: http_status:404
</code></pre>
<pre><code class="language-bash"># 启动 tunnel（作为 systemd 服务）
cloudflared service install
systemctl start cloudflared
</code></pre>
<p dir="auto">Cloudflare Tunnel 的好处：<strong>零暴露</strong>（没有开端口、没有公网 IP 映射）、自带 DDoS 防护、可加 Access 策略做额外认证。</p>
<h3>轻量替代方案</h3>
<p dir="auto">如果不想用 Cloudflare，可以用 <strong>frp</strong> 做反向代理：</p>
<pre><code class="language-bash"># 服务端（公网 VPS）
frps -c frps.toml

# 客户端（内网 Ubuntu）
frpc -c frpc.toml
</code></pre>
<p dir="auto"><code>frpc.toml</code>:</p>
<pre><code class="language-toml">serverAddr = "your-vps-ip"
serverPort = 7000

&lsqb;&lsqb;proxies&rsqb;&rsqb;
name = "llama-server"
type = "tcp"
localIP = "127.0.0.1"
localPort = 8080
remotePort = 8080
</code></pre>
<h3>性能考虑</h3>
<ul>
<li>公网穿透会引入额外延迟（Cloudflare ~20-50ms，frp ~5-15ms）</li>
<li>对于短对话（低 token）影响不大</li>
<li>对于长上下文（大量 prefill）主要耗时在推理本身，网络延迟占比小</li>
<li>建议在客户端侧加 <strong>keep-alive</strong> 和 <strong>连接复用</strong>，避免每次请求重新建 TCP 连接</li>
</ul>
<h2>避坑指南</h2>
<h3>1. 不要用 <code>-fa on</code>（Flash Attention）</h3>
<p dir="auto">ROCm 下 Flash Attention 绝大部分版本默认启用（<code>auto</code>），显式指定反而不一定兼容。如果让它自动检测，它会在支持的设备上自动开启，不支持的设备上自动降级。</p>
<h3>2. 双卡用户注意 PCIe 瓶颈</h3>
<p dir="auto">双 R9700 用 <code>--split-mode tensor</code> 会因为 PCIe 瓶颈导致 Prefill 降到 19 tok/s。推荐用 <code>--split-mode layer</code> 按层切分。单卡用户无此问题。</p>
<h3>3. <code>--cache-type-k/v q8_0</code> 一定要加</h3>
<p dir="auto">这是<strong>性价比最高的优化</strong>。默认 f16 的 KV cache 吃显存非常多。q8_0 质量损失几乎不可感知（Q4_K_M 权重才是主要误差来源），但显存占用减半。</p>
<h3>4. <code>--no-cache-prompt</code> + <code>--cache-ram 0</code> 防崩组合</h3>
<p dir="auto">llama-server 的跨请求 prompt cache 在长时间运行的场景下有时会触发 segfault 或卡死。禁用后每次请求重新处理 prompt，速度略降但稳定性大幅提升。</p>
<h3>5. <code>--mlock</code> 防止 swap 降速</h3>
<p dir="auto">单卡 32GB 跑 27B Q4_K_M 时，系统可能会把部分页面 swap 到硬盘。<code>--mlock</code> 锁定物理内存页，避免推理过程中卡在缺页中断。</p>
<h3>6. MTP/Eagle2 模型可进一步提速</h3>
<p dir="auto">如果有 Qwen3.6 的 Eagle2/MTP 版本（Multi-Token Prediction），Prefill 速度可从 ~186 tok/s 提升到 ~562 tok/s（3x）。目前没有公开的 GGUF 版本，有条件的可以自己从官方权重导出。</p>
<h2>总结</h2>
<p dir="auto">单卡 AMD Radeon AI Pro R9700 (32GB) + Qwen3.6-27B Q4_K_M 是一个<strong>生产可用</strong>的本地推理方案：</p>
<ul>
<li>编程助手、代码补全、工具调用 — 流畅无压力</li>
<li>128K 上下文 — 日常使用足够</li>
<li>Hermes Agent + Claude Code 直连 — 无需代理，延迟最低</li>
<li>VRAM 余量 ~30% — 不会 OOM</li>
<li>256K 上下文 — 速度太慢，不推荐</li>
<li>超长文档处理 — 27B 模型的推理速度上限在那，建议降级到 14B 以下</li>
</ul>
<p dir="auto">总体感受：Qwen3.6-27B 的推理能力极强，工具调用准确，配合 Hermes Agent 联网检索效果很好。对于预算有限（一块 R9700 卡 + 普通 PC）又想跑本地大模型的用户来说，这个配置是目前性价比最高的方案之一。</p>
]]></description><link>https://lcz.me/topic/718/单卡-amd-radeon-ai-pro-r9700-32gb-qwen3.6-27b-hermes-agent-本地部署经验-llm公网部署</link><generator>RSS for Node</generator><lastBuildDate>Wed, 01 Jul 2026 11:08:44 GMT</lastBuildDate><atom:link href="https://lcz.me/topic/718.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 27 Jun 2026 13:13:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 单卡 AMD Radeon AI Pro R9700 (32GB) + Qwen3.6-27B + Hermes Agent 本地部署经验+LLM公网部署 on Sat, 27 Jun 2026 14:42:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/566656661" aria-label="Profile: 566656661">@<bdi>566656661</bdi></a> 设个api就好了</p>
]]></description><link>https://lcz.me/post/8566</link><guid isPermaLink="true">https://lcz.me/post/8566</guid><dc:creator><![CDATA[loulan]]></dc:creator><pubDate>Sat, 27 Jun 2026 14:42:17 GMT</pubDate></item><item><title><![CDATA[Reply to 单卡 AMD Radeon AI Pro R9700 (32GB) + Qwen3.6-27B + Hermes Agent 本地部署经验+LLM公网部署 on Sat, 27 Jun 2026 14:13:44 GMT]]></title><description><![CDATA[<p dir="auto">我自己有試過用Cloudflare跟Tailscale把目前的vLLM放到公網</p>
<p dir="auto">注重隱秘的話就選Tailscale<br />
注重安全 + 方便的話就選Cloudflare</p>
<p dir="auto">Cloudflare 因爲内部Caching, WAF rule enforcement的關係基本上資料在Cloudflare内部是裸奔的狀態</p>
]]></description><link>https://lcz.me/post/8555</link><guid isPermaLink="true">https://lcz.me/post/8555</guid><dc:creator><![CDATA[566656661]]></dc:creator><pubDate>Sat, 27 Jun 2026 14:13:44 GMT</pubDate></item><item><title><![CDATA[Reply to 单卡 AMD Radeon AI Pro R9700 (32GB) + Qwen3.6-27B + Hermes Agent 本地部署经验+LLM公网部署 on Sat, 27 Jun 2026 13:30:45 GMT]]></title><description><![CDATA[<p dir="auto">实际公网部署用的codex gpt5.5完成临门一脚，deepseek v4 flash在这一块没有gpt强，也不差了，但还差临门一脚它就是配不成，最后用的codex gpt5.5完成临门一脚。公网调用速度感觉不慢。纯完美替代各种在线模型。</p>
]]></description><link>https://lcz.me/post/8538</link><guid isPermaLink="true">https://lcz.me/post/8538</guid><dc:creator><![CDATA[loulan]]></dc:creator><pubDate>Sat, 27 Jun 2026 13:30:45 GMT</pubDate></item></channel></rss>