<?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[5090D+Qwen3.8-27B-NVFP4+ SGLang+ WSL 部署方案文档]]></title><description><![CDATA[<h1>Qwen3.8-27B SGLang 推理服务 · WSL 部署方案文档</h1>
<blockquote>
<p dir="auto">项目：<a href="https://github.com/darksidewalker/qwen3.8-27b-sglang-dspark-blackwell" rel="nofollow ugc">darksidewalker/qwen3.8-27b-sglang-dspark-blackwell</a>内容：NVFP4 量化版 Qwen3.8-27B + DSpark 投机解码 drafter，单张 RTX 5090（32GB）高吞吐推理整理日期：2026-08-22（基于实际部署过程复盘）</p>
</blockquote>
<hr />
<h2>一、项目概述</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>项</th>
<th>说明   ---------------------------以下由AI整理</th>
</tr>
</thead>
<tbody>
<tr>
<td>模型</td>
<td>Qwen3.8-27B，NVFP4 权重 + NVFP4 lm_head + FP8 KV cache</td>
</tr>
<tr>
<td>加速</td>
<td>DSpark drafter 投机解码（草稿块整体验证），实测峰值 ~300 tok/s 级</td>
</tr>
<tr>
<td>引擎</td>
<td>SGLang 官方预构建镜像 <code>lmsysorg/sglang:qwen38-27b</code>（免 JIT 编译）</td>
</tr>
<tr>
<td>显存占用</td>
<td>godspeed 约 31 GB / 32 GB；vision 约 30 GB</td>
</tr>
<tr>
<td>上下文</td>
<td>godspeed（纯文本）237,568 tok；vision 150,000 tok，wsl环境上下文设置200K，DeepSeek-herness调用正常，速度非常快</td>
</tr>
<tr>
<td>服务端口</td>
<td>API <strong>8040</strong> · Caddy 网关 8041 · Grafana 8042 · Prometheus 127.0.0.1:9091</td>
</tr>
<tr>
<td>模型 ID</td>
<td><code>qwen3.8-27b-nvfp4</code>（<code>--served-model-name</code> 固定，OpenAI 兼容接口）</td>
</tr>
</tbody>
</table>
<p dir="auto"><img src="https://upload.lcz.me/uploads/8bcbaa7a-7c58-4ab7-8b80-9f9f080a1fa6.png" alt="屏幕截图 2026-08-22 150228.png" class=" img-fluid img-markdown" /></p>
<h3>硬件 / 系统要求</h3>
<ul>
<li>Linux x86_64（本方案为 WSL2 Ubuntu 22.04）</li>
<li>NVIDIA RTX 5090 / 5090D（Blackwell sm_120），<strong>驱动 ≥ 580</strong>（本机 610.43.02，CUDA UMD 13.3）</li>
<li>磁盘：镜像约 41 GB + 权重约 20 GB</li>
</ul>
<h3>本机实际环境</h3>
<pre><code>WSL2 内核 6.18.33.2-microsoft-standard-WSL2 · Ubuntu 22.04 (jammy)
GPU: NVIDIA GeForce RTX 5090 D 32GB
CPU:9850X3D【游戏佬】
内存：DDR5 48G  WSL划分38G
docker-ce 29.7.2 + containerd 2.3.3（systemd 服务，enabled 自启）
nvidia-container-toolkit 1.20.0（daemon.json 已注册 nvidia runtime）
docker daemon 走代理 127.0.0.1:10809（http-proxy.conf drop-in）
</code></pre>
<hr />
<h2>二、部署流程（WSL 适用）</h2>
<h3>步骤 0 · 前置检查</h3>
<pre><code>nvidia-smi                          # 确认驱动 ≥ 580、GPU 可见
docker info | grep -i nvidia        # 确认 nvidia runtime 已注册
docker ps                           # 确认 CLI 与守护进程通信正常
</code></pre>
<h3>步骤 1 · 克隆项目</h3>
<pre><code>cd ~
git clone https://github.com/darksidewalker/qwen3.8-27b-sglang-dspark-blackwell.git sglang
cd ~/sglang
cp .env.example .env                # 默认值即可跑通，按需修改
</code></pre>
<h3>步骤 2 · 脚本 Docker 化改造（关键步骤，见第四章）</h3>
<p dir="auto">原项目面向 Podman 编写，在 Docker 环境必须先改 4 个脚本：<code>setup.sh</code>、<code>run-sglang-godspeed.sh</code>、<code>run-sglang-vision.sh</code>、<code>monitor.sh</code></p>
<h3>步骤 3 · 拉取镜像 + 准备权重</h3>
<pre><code>docker pull lmsysorg/sglang:qwen38-27b     # ~41 GB，走国内镜像加速
./setup.sh                                  # 或手动下载权重到 ./models/
</code></pre>
<p dir="auto">权重目录结构（本机实际布局，主模型 18G + drafter 1.4G）：</p>
<pre><code>~/sglang/models/
├── Qwen3.8-27B-NVFP4-RTX5090-LMHead4/    # 主模型（target）
└── Qwen3.8-27B-DSpark-NVFP4/             # DSpark drafter
</code></pre>
<blockquote>
<p dir="auto">大文件建议手动下载后放入对应目录（HuggingFace 后台直连下载易中断留半截文件）。</p>
</blockquote>
<h3>步骤 4 · 启动与验证</h3>
<pre><code>./run-sglang-godspeed.sh start      # 纯文本模式（最快）
./run-sglang-godspeed.sh status     # 反复执行直到 "HTTP 200 (ready)"，首次加载约 1-2 分钟
</code></pre>
<p dir="auto">验证三连：</p>
<pre><code># 1. 模型列表
curl -s http://localhost:8040/v1/models

# 2. 实际推理（含思维链）
curl -s http://localhost:8040/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"qwen3.8-27b-nvfp4","messages":[{"role":"user","content":"你好"}],"max_tokens":100}'

# 3. GPU 占用（应接近 30.8/32.6 GB）
nvidia-smi
</code></pre>
<p dir="auto">实测结果：推理正常返回且带 <code>reasoning_content</code> 思维链字段；GPU 30822/32607 MiB。</p>
<h3>步骤 5 · （可选）监控仪表盘</h3>
<pre><code>./monitor.sh up          # Grafana 8042 / Prometheus 9091 / Caddy 8041
./monitor.sh dashboard   # 打印面板地址和登录提示
./monitor.sh status      # sglang target 仅在推理服务运行时为 UP，属正常
</code></pre>
<hr />
<h2>三、部署过程中遇到的问题</h2>
<h3>问题 1 ★核心故障 · docker 命令全部卡死</h3>
<p dir="auto"><strong>现象</strong>：任何 <code>docker xxx</code> 命令无限挂起（<code>docker ps</code> 卡死无输出）。</p>
<p dir="auto"><strong>根因</strong>：<code>/usr/bin/docker</code> 曾被替换为一个「podman 语法翻译」包装脚本——它把参数里的<code>--device nvidia.com/gpu=all</code> 改写为 <code>--gpus all</code>，最后执行 <code>exec docker "${args[@]}"</code>。但 PATH 解析时 <code>docker</code> 找到的就是它自己 → <strong>无限 exec 递归</strong>，永不返回。</p>
<p dir="auto"><strong>诊断方法</strong>：</p>
<pre><code>file /usr/bin/docker        # 输出 "Bourne-Again shell script" = 异常
                            # 正常应为 "ELF 64-bit LSB pie executable"
</code></pre>
<p dir="auto"><strong>正确修复</strong>（从本地 apt 缓存解出真二进制覆盖，无需联网）：</p>
<pre><code># 1. 确认已安装版本
dpkg -l docker-ce-cli       # 例: 5:29.7.2-1~ubuntu.22.04~jammy

# 2. 版本必须与守护进程一致，从缓存 deb 解出
dpkg -x /var/cache/apt/archives/docker-ce-cli_&lt;版本串&gt;.deb /tmp/x
file /tmp/x/usr/bin/docker | grep ELF    # 先验明正身再覆盖

# 3. 覆盖回去
sudo cp /tmp/x/usr/bin/docker /usr/bin/docker
sudo chown root:root /usr/bin/docker &amp;&amp; sudo chmod 755 /usr/bin/docker
</code></pre>
<p dir="auto"><strong>教训</strong>：给 <code>/usr/bin/</code> 下的真实二进制做同名包装脚本时，包装器内部绝不能再以裸命令名调用自身。</p>
<h3>问题 2 · 修复放错位置，重启后复发</h3>
<p dir="auto"><strong>现象</strong>：第一次修复把真二进制解压到 <code>/tmp/docker-extract/</code>，再用 PATH 前缀的 shim 指过去。当时能用，<strong>WSL 重启后全部失效</strong>。</p>
<p dir="auto"><strong>根因</strong>：Ubuntu 每次 WSL 启动会自动清空 <code>/tmp</code>（tmpfiles 清理机制）。放在 /tmp 的二进制没了，shim 变成死链；同时裸 <code>docker</code> 又命中 /usr/bin 下的递归包装脚本 → 故障复现。</p>
<p dir="auto"><strong>教训</strong>：持久化修复必须落在系统盘常规路径（如 <code>/usr/bin/</code>）；<code>/tmp</code> 只能放临时产物。</p>
<h3>问题 3 · WSL 重启后服务消失（非故障）</h3>
<p dir="auto"><strong>现象</strong>：WSL 重启后 API 8040 无响应，容器状态 <code>Exited (0)</code>。</p>
<p dir="auto"><strong>说明</strong>：这是正常行为。WSL 关闭时 systemd 有序终止 dockerd 与容器（退出码 0 = 干净退出），显存随之释放。dockerd 是 enabled 服务会自启，但业务容器需要手动拉起：</p>
<pre><code>cd ~/sglang &amp;&amp; ./run-sglang-godspeed.sh start
</code></pre>
<p dir="auto">关闭 WSL 时<strong>不需要</strong>单独停 docker 或容器，Windows 侧直接关即可。</p>
<h3>问题 4 · 双目录混淆</h3>
<p dir="auto"><strong>现象</strong>：<code>~/sglang</code>（原版克隆）与 <code>~/sglang-qwen</code>（改过的副本）并存，在旧目录里启动报<code>podman: command not found</code>。</p>
<p dir="auto"><strong>处置</strong>：修好的脚本 + <code>.env</code> 全部迁回 <code>~/sglang</code>（权重实体本来就在它的 models/ 下），删除冗余的 <code>~/sglang-qwen</code>。现在全系统只有一个入口 <code>~/sglang</code>。</p>
<p dir="auto"><strong>教训</strong>：克隆副本要及时合并回主目录或明确改名区分，避免「改了 A 跑了 B」。</p>
<h3>问题 5 · 无免密 sudo 的自动化障碍</h3>
<p dir="auto"><strong>现象</strong>：WSL 用户未配置 NOPASSWD，脚本化提权受阻。</p>
<p dir="auto"><strong>处置</strong>：密码存于 <code>~/.hermes/.env</code>（SUDO_PASSWORD 变量），配合 askpass 脚本：</p>
<pre><code>set -a; source ~/.hermes/.env; set +a
export SUDO_ASKPASS=$HOME/.hermes/sudo-askpass.sh   # 脚本内容: printf "%s" "$SUDO_PASSWORD"
sudo -A &lt;命令&gt;
</code></pre>
<hr />
<h2>四、原作者的非标准 Docker 问题及修复方案</h2>
<h3>4.1 原作者的方案是什么</h3>
<p dir="auto">原作者环境不用 Docker，而是 <strong>rootless Podman</strong> 技术栈：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>维度</th>
<th>原作者（Podman）</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>容器引擎</td>
<td>Podman（rootless 无守护进程）</td>
<td>非 Docker</td>
</tr>
<tr>
<td>GPU 透传</td>
<td><code>--device nvidia.com/gpu=all</code></td>
<td>依赖 NVIDIA <strong>CDI</strong> 规范</td>
</tr>
<tr>
<td>编排</td>
<td>podman-compose</td>
<td>非 docker compose</td>
</tr>
</tbody>
</table>
<p dir="auto">README 明确写了：<em>"Equivalent Docker + nvidia-container-toolkit also works; the scriptscall <code>podman</code>, add a shim if you use Docker."</em> —— 即官方认可 Docker 等效可行，但所有脚本硬编码调用 <code>podman</code>，Docker 用户要么加 shim 要么改脚本。</p>
<h3>4.2 为什么在本机不能直接用 Podman 方案</h3>
<ul>
<li>本机已装好完整 Docker CE 29.7.2 + nvidia-container-toolkit，daemon.json 已注册 nvidia runtime，再引入 Podman 属于重复建设；</li>
<li>WSL2 下 rootless Podman 配置链路更长（uidmap/subuid/CDI 注册），维护成本高于现成 Docker。</li>
</ul>
<h3>4.3 修复方案：脚本 Docker 化（采用的方案）</h3>
<p dir="auto">对 4 个脚本做系统性替换：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>原写法（Podman）</th>
<th>改为（Docker）</th>
<th>出现位置</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>podman pull</code> / <code>podman image inspect</code></td>
<td><code>docker pull</code> / <code>docker image inspect</code></td>
<td><a href="http://setup.sh" rel="nofollow ugc">setup.sh</a>, run-*.sh</td>
</tr>
<tr>
<td><code>podman run -d ...</code></td>
<td><code>docker run -d ...</code></td>
<td>run-*.sh</td>
</tr>
<tr>
<td><code>--device nvidia.com/gpu=all</code></td>
<td><code>--gpus all</code></td>
<td>run-*.sh（GPU 透传的关键差异）</td>
</tr>
<tr>
<td><code>podman rm -f</code> / <code>podman ps</code> / <code>podman logs</code></td>
<td><code>docker rm -f</code> / <code>docker ps</code> / <code>docker logs</code></td>
<td>run-*.sh</td>
</tr>
<tr>
<td><code>podman network create/inspect</code></td>
<td><code>docker network create/inspect</code></td>
<td>run-*.sh（监控网络互通）</td>
</tr>
<tr>
<td><code>podman-compose -f docker-compose.yml up -d</code></td>
<td><code>docker compose -f docker-compose.yml up -d</code></td>
<td><a href="http://monitor.sh" rel="nofollow ugc">monitor.sh</a></td>
</tr>
</tbody>
</table>
<p dir="auto">GPU 透传差异的本质：</p>
<ul>
<li>Podman/CDI 把 GPU 当作「设备」挂载，语法是 <code>--device nvidia.com/gpu=all</code>；</li>
<li>Docker 用 nvidia-container-toolkit 的专用参数 <code>--gpus all</code>（等价效果，底层同样走 libnvidia-container）；</li>
<li>两者的 daemon.json 侧配置不同（CDI 注册 vs nvidia runtime 注册），不可混用语法。</li>
</ul>
<h3>4.4 备选方案：shim 适配层（曾用过，已弃）</h3>
<p dir="auto">即保持脚本不动，在 PATH 前置一个 <code>podman</code> 命令 shim 转发给 docker 并翻译参数。本项目早期还额外写过反向 shim（把脚本的 <code>--device</code> 语法翻译成 <code>--gpus</code>）。</p>
<p dir="auto"><strong>弃用原因</strong>：</p>
<ol>
<li>shim 若依赖 /tmp 存放真二进制，WSL 重启即碎（见问题 2）；</li>
<li>参数翻译层是额外的出错面（本项目就因翻译层递归把自己卡死，见问题 1）；</li>
<li>直接改脚本是一次性的、可审计的 diff，长期维护成本最低。</li>
</ol>
<p dir="auto"><strong>结论</strong>：一次性项目优先直接改脚本；只有脚本不可改动（如只读镜像内）才考虑 shim。</p>
<hr />
<h2>五、日常运维速查</h2>
<h3>服务管理</h3>
<pre><code>cd ~/sglang
./run-sglang-godspeed.sh start     # 启动（纯文本，最快）
./run-sglang-godspeed.sh status    # 状态 + 就绪检查
./run-sglang-godspeed.sh logs      # 跟踪日志
./run-sglang-godspeed.sh stop      # 停止
./run-sglang-vision.sh start       # 切视觉模式（同一 GPU 二选一，先 stop 再 start）
</code></pre>
<h3>API 调用</h3>
<pre><code>curl -s http://localhost:8040/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"qwen3.8-27b-nvfp4","messages":[{"role":"user","content":"你好"}]}'
</code></pre>
<p dir="auto">思维链控制（<code>.env</code> 中 <code>DEFAULT_CHAT_TEMPLATE_KWARGS</code>，默认 medium）：</p>
<pre><code>{"reasoning_effort": "low"}           // 更快更省
{"reasoning_effort": "xhigh"}         // 更深思考
{"enable_thinking": false}            // 完全关闭思维链
</code></pre>
<p dir="auto">也可单请求覆盖不重启：请求体加 <code>"chat_template_kwargs":{"reasoning_effort":"xhigh"}</code>。</p>
<h3>常用 .env 参数</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>参数</th>
<th>默认</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>HOST_PORT</td>
<td>8040</td>
<td>对外 API 端口</td>
</tr>
<tr>
<td>SERVED_MODEL_NAME</td>
<td>qwen3.8-27b-nvfp4</td>
<td>/v1/models 暴露的 ID</td>
</tr>
<tr>
<td>CONTAINER_NAME</td>
<td>sglang-qwen38</td>
<td>容器名</td>
</tr>
<tr>
<td>SGGLANG_IMAGE</td>
<td>lmsysorg/sglang:qwen38-27b</td>
<td>镜像</td>
</tr>
<tr>
<td>DEFAULT_CHAT_TEMPLATE_KWARGS</td>
<td>{"reasoning_effort":"medium"}</td>
<td>思维链开关</td>
</tr>
</tbody>
</table>
<h3>故障速查表</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>症状</th>
<th>排查方向</th>
</tr>
</thead>
<tbody>
<tr>
<td>docker 命令卡死</td>
<td><code>file /usr/bin/docker</code> 应为 ELF；若为 script 按第三章问题 1 修复</td>
</tr>
<tr>
<td>启动报 <code>podman: command not found</code></td>
<td>在错误目录跑了旧脚本，确认 <code>cd ~/sglang</code></td>
</tr>
<tr>
<td>status 一直 503</td>
<td>首次加载权重需 1-2 分钟，看 <code>logs</code>；显存不足时先释放 GPU</td>
</tr>
<tr>
<td>vision 启动 OOM</td>
<td>降 <code>--mem-fraction-static</code> 至 0.80、上下文至 ~120k（README 建议）</td>
</tr>
<tr>
<td>Prometheus target DOWN</td>
<td>未启动推理服务时属正常，服务 ready 后自动恢复</td>
</tr>
<tr>
<td>WSL 重启后 API 不通</td>
<td>容器随 WSL 停止，手动 <code>start</code> 即可（正常现象）</td>
</tr>
</tbody>
</table>
<hr />
<h2>六、附录 · 关键文件清单</h2>
<pre><code>~/sglang/
├── .env                      # 本机生效配置（含端口/镜像/模型仓库名）
├── .env.example              # 配置模板
├── setup.sh                  # 拉镜像+下载权重（已 Docker 化）
├── run-sglang-godspeed.sh    # 纯文本预设 start|stop|logs|status（已 Docker 化）
├── run-sglang-vision.sh      # 视觉预设（已 Docker 化）
├── monitor.sh                # 监控栈管理（已 Docker 化，docker compose）
├── docker-compose.yml        # caddy/prometheus/grafana/dcgm 四件套
├── make_dashboard.py         # Grafana 面板生成器
└── models/                   # 权重实体（18G 主模型 + 1.4G drafter）
    ├── Qwen3.8-27B-NVFP4-RTX5090-LMHead4/
    └── Qwen3.8-27B-DSpark-NVFP4/

/usr/bin/docker                # 真 CLI 二进制 v29.7.2（勿用脚本覆盖！）
/etc/docker/daemon.json        # registry-mirrors + nvidia runtime
/etc/systemd/system/docker.service.d/http-proxy.conf   # daemon 代理 127.0.0.1:10809
</code></pre>
]]></description><link>https://lcz.me/topic/1264</link><generator>RSS for Node</generator><lastBuildDate>Thu, 10 Sep 2026 06:04:57 GMT</lastBuildDate><atom:link href="https://lcz.me/topic/1264.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 22 Aug 2026 07:04:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 5090D+Qwen3.8-27B-NVFP4+ SGLang+ WSL 部署方案文档 on Sun, 23 Aug 2026 16:18:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/williamlouis" aria-label="Profile: williamlouis">@<bdi>williamlouis</bdi></a> 游戏也保不了多久了，G胖正在推SteamOS，到时候大家抄下作业。最主要的是AI会帮你配置系统，我想快了，把我最后的windows笔记本格式化，装Linux。</p>
]]></description><link>https://lcz.me/post/13638</link><guid isPermaLink="true">https://lcz.me/post/13638</guid><dc:creator><![CDATA[terry]]></dc:creator><pubDate>Sun, 23 Aug 2026 16:18:29 GMT</pubDate></item><item><title><![CDATA[Reply to 5090D+Qwen3.8-27B-NVFP4+ SGLang+ WSL 部署方案文档 on Sun, 23 Aug 2026 08:10:09 GMT]]></title><description><![CDATA[<p dir="auto">我猜就是这样的。尤其是游戏。应该是windows 最后的保命稻草了。</p>
]]></description><link>https://lcz.me/post/13566</link><guid isPermaLink="true">https://lcz.me/post/13566</guid><dc:creator><![CDATA[williamlouis]]></dc:creator><pubDate>Sun, 23 Aug 2026 08:10:09 GMT</pubDate></item><item><title><![CDATA[Reply to 5090D+Qwen3.8-27B-NVFP4+ SGLang+ WSL 部署方案文档 on Sun, 23 Aug 2026 07:59:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/williamlouis" aria-label="Profile: williamlouis">@<bdi>williamlouis</bdi></a> 写代码也在这个机子上，游戏办公，llm,comfyui都在这一台机子。DeepSeek harness 可以在外面随时随地发指令挺好的。</p>
]]></description><link>https://lcz.me/post/13563</link><guid isPermaLink="true">https://lcz.me/post/13563</guid><dc:creator><![CDATA[随心录]]></dc:creator><pubDate>Sun, 23 Aug 2026 07:59:01 GMT</pubDate></item><item><title><![CDATA[Reply to 5090D+Qwen3.8-27B-NVFP4+ SGLang+ WSL 部署方案文档 on Sat, 22 Aug 2026 14:43:40 GMT]]></title><description><![CDATA[<p dir="auto">做为大模型服务器之外。这个主机还有别的必须使用 windows 系统的任务吧？而且这个 任务必须在 windows 下运行。</p>
]]></description><link>https://lcz.me/post/13485</link><guid isPermaLink="true">https://lcz.me/post/13485</guid><dc:creator><![CDATA[williamlouis]]></dc:creator><pubDate>Sat, 22 Aug 2026 14:43:40 GMT</pubDate></item></channel></rss>