<?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[Proxmox VE 9.2+ Intel 核显 SR-IOV + AMD Radeon AI PRO R9700 直通+Ubuntu24.04部署实测（一）]]></title><description><![CDATA[<h2>一. 方案概述</h2>
<pre><code>Proxmox VE 9.2 宿主（headless）
  主机：ASUS TUF GAMING Z890-PRO WIFI / Core Ultra 7 265K / 64GB

① Intel 核显 00:02.0（PF，留给宿主 i915 管理）
     ├─ 00:02.1 VF  -&gt;  办公/学习 VM-1（解码加速）
     ├─ 00:02.2 VF  -&gt;  办公/学习 VM-2
     ├─ 00:02.3 VF  -&gt;  办公/学习 VM-3
     ├─ 00:02.4 VF  -&gt;  办公/学习 VM-4
    

② AMD R9700 04:00.0（整卡直通）
     └─&gt; Ubuntu 24.04 算力 VM
           └─&gt; ROCm + llama.cpp（Qwen3.8-27B）+ DeepSeek Harness WebUI
</code></pre>
<h2>二. 本机配置</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>组件</th>
<th>型号/参数</th>
</tr>
</thead>
<tbody>
<tr>
<td>主板</td>
<td>ASUS TUF GAMING Z890-PRO WIFI</td>
<td>BIOS 3211</td>
</tr>
<tr>
<td>CPU</td>
<td>Intel Core Ultra 7 265K</td>
<td>Arrow Lake-S，20 核</td>
</tr>
<tr>
<td>内存</td>
<td>64GB DDR5-6400（2×32GB 双通道）</td>
<td></td>
</tr>
<tr>
<td>核显</td>
<td>Intel 8086:7d67（Xe-LPG，驱动识别为 meteorlake）</td>
<td><strong>SR-IOV 能力已实测：<code>sriov_totalvfs=4</code></strong></td>
</tr>
<tr>
<td>独显</td>
<td>AMD Radeon AI PRO R9700（gfx1201/RDNA4，32GB）</td>
<td>地址 <code>04:00.0</code></td>
</tr>
<tr>
<td>启动盘</td>
<td>Samsung MZAMX512HCLV-00BL2 512 GB（LVM</td>
<td><code>pve-root</code> 461 G + <code>pve-swap</code> 8 G，ext4）</td>
</tr>
<tr>
<td>数据盘</td>
<td>Kingston SNV2S1000G 1 TB</td>
<td>（<strong>整块直通给 VM 102 Ubuntu24.04</strong>）</td>
</tr>
<tr>
<td>系统现状</td>
<td>Ubuntu 24.04.5，内核 7.0.0-31-generic</td>
<td>加载llama.cpp+AMD AI Pro R9700</td>
</tr>
</tbody>
</table>
<h2>三.  方案可行性结论（已核实）</h2>
<pre><code>
1. **核显 SR-IOV 可行**：本机核显实测具备 `Single Root I/O Virtualization` 能力，`sriov_totalvfs=7`（最多 7 个 VF，本方案用 5 个）。Intel 官方支持列表含 Arrow Lake（Core Ultra 200 / Series 2）。
2. **VF 定位为解码加速**：VF 只做渲染/解码（guest 内表现为 `/dev/dri/renderD128`，走 VAAPI/QSV），**不驱动物理 HDMI/DP**。主显示走 virtio-gpu/Spice/RDP，远程连接使用——这正是 Intel vGPU 云桌面的标准用法。
3. **AMD R9700 直通可行**：社区已有双 R9700 在 Proxmox 上跑 llama.cpp 的成功案例，单卡更简单。

</code></pre>
<h2>四. 前置准备（BIOS 设置）</h2>
<p dir="auto">进入 BIOS 确认（这些是 SR-IOV 和直通的共同前提）：</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>设置</th>
<th>值</th>
</tr>
</thead>
<tbody>
<tr>
<td>Intel VT-d</td>
<td><strong>Enabled</strong></td>
</tr>
<tr>
<td>Above 4G Decoding</td>
<td><strong>Enabled</strong>（VF BAR 需要大地址空间）</td>
</tr>
<tr>
<td>Re-Size BAR Support</td>
<td><strong>Enabled</strong></td>
</tr>
<tr>
<td>Secure Boot</td>
<td><strong>Disabled</strong>（你已是 disabled，保持即可）</td>
</tr>
<tr>
<td>CSM</td>
<td><strong>Disabled</strong></td>
</tr>
</tbody>
</table>
<blockquote>
<p dir="auto">参考：内核日志里 VF BAR 的预留是 <code>VF BAR 0 ... contains BAR 0 for 7 VFs</code>，说明固件确实为 7 个 VF 预留了 MMIO 空间。如果 4 个 VF 建不起来，优先回查 Above 4G Decoding 与 Re-Size BAR。</p>
</blockquote>
<h3>步骤 1：安装编译工具链与内核头文件</h3>
<pre><code class="language-bash">apt update
apt install -y build-essential dkms sysfsutils pciutils wget

# 头文件必须与当前运行内核严格对应
apt install -y proxmox-headers-$(uname -r)

# 校验
ls -d /usr/src/linux-headers-$(uname -r)
</code></pre>
<blockquote>
<p dir="auto">如果你的 <code>uname -r</code> 不是 <code>7.0.14-16-pve</code>，把命令里的版本换成实际值。也可以用 <code>proxmox-default-headers</code> 跟随默认内核。</p>
</blockquote>
<h3>步骤 2：安装 i915-sriov-dkms</h3>
<p dir="auto">当前最新版 <strong><code>2026.08.12.1</code></strong>，要求内核 <strong>6.17.x ~ 7.1.x</strong> —— 本机的 <code>7.0.14-16-pve</code> <strong>在支持范围内</strong>。</p>
<pre><code class="language-bash">wget -O /tmp/i915-sriov-dkms_2026.08.12.1_amd64.deb \
  "https://github.com/strongtz/i915-sriov-dkms/releases/download/2026.08.12.1/i915-sriov-dkms_2026.08.12.1_amd64.deb"

dpkg -i /tmp/i915-sriov-dkms_2026.08.12.1_amd64.deb

# 关键：确认 DKMS 针对本机的内核编译成功
dkms status
# 期望输出：i915-sriov-dkms/2026.08.12.1, 7.0.14-16-pve, x86_64: installed
</code></pre>
<p dir="auto"><strong>若 <code>dkms status</code> 没有 <code>installed</code>，先不要重启</strong>，否则可能起不来图形/核显。排查：</p>
<pre><code class="language-bash">cat /var/lib/dkms/i915-sriov-dkms/2026.08.12.1/build/make.log | tail -40
</code></pre>
<h3>步骤 3：配置内核参数（i915 路径）</h3>
<p dir="auto">编辑 <code>/etc/default/grub</code>，把第 9 行改成：</p>
<pre><code>GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on i915.enable_guc=3 i915.max_vfs=4 module_blacklist=xe"
</code></pre>
<p dir="auto">要点说明：</p>
<ul>
<li><code>intel_iommu=on</code> —— 直通与 VF 隔离前提（当前没写，但 R9700 已在用，说明内核默认开了；显式写上更稳妥）。</li>
<li><code>i915.enable_guc=3</code> —— 启用 GuC + HuC，SR-IOV 必需。<strong>本机当前的 GuC 已经在跑</strong>（<code>GuC firmware i915/mtl_guc_70.bin version 70.53.0</code>，submission/SLPC/RC 均已启用），加这个参数是确保补丁版驱动下依然加载。</li>
<li><code>i915.max_vfs=4</code> —— <strong>我要 4 个 VF，所以写 4</strong>（硬件上限 7；写 4 就只创建 4 个，不浪费 BAR 空间）。</li>
<li><code>module_blacklist=xe</code> —— <strong>硬性要求</strong>。本机当前 <code>xe</code> 已加载（0 引用），必须屏蔽。</li>
</ul>
<p dir="auto">应用：</p>
<pre><code class="language-bash">update-grub
update-initramfs -u -k all
</code></pre>
<h3>步骤 4：开机自动创建 VF</h3>
<p dir="auto">DKMS 模块装好后，VF 仍需通过 sysfs 显式创建。用 <code>sysfsutils</code> 让它在开机时自动执行：</p>
<pre><code class="language-bash">echo "devices/pci0000:00/0000:00:02.0/sriov_numvfs = 4" &gt; /etc/sysfs.conf

# 确认写入
cat /etc/sysfs.conf
</code></pre>
<blockquote>
<p dir="auto">官方 PVE 指南用的就是这一步。只写 grub 参数而不配 <code>sysfs.conf</code>，重启后 <code>sriov_numvfs</code> 仍是 0，VF 不会出现。</p>
</blockquote>
<h3>步骤 5：把 VF 在宿主上屏蔽</h3>
<p dir="auto">VF 留在宿主上会导致系统不稳定、软件冲突，也可能被宿主的转码软件误用。官方明确建议屏蔽。</p>
<blockquote>
<p dir="auto"><img src="https://lcz.me/assets/plugins/nodebb-plugin-emoji/emoji/android/26a0.png?v=efcae6a46b1" class="not-responsive emoji emoji-android emoji--warning" style="height:23px;width:auto;vertical-align:middle" title="⚠" alt="⚠" />️ <strong>注意：已经有 <code>/etc/modprobe.d/vfio.conf</code>（给 R9700 用的 <code>options vfio-pci ids=1002:7551,1002:ab40</code>）。下面这条命令会新建 modules-load 配置，不会覆盖你现有的 vfio.conf。但请先确认，不要手工去改 vfio.conf 而把 AMD 的配置弄丢。</strong></p>
</blockquote>
<pre><code class="language-bash"># 让 vfio-pci 开机加载
echo "vfio-pci" &gt; /etc/modules-load.d/vfio.conf
</code></pre>
<p dir="auto">创建 udev 规则（<strong>设备 ID 用你的 <code>0x7d67</code>，VF 范围 1–4</strong>）：</p>
<pre><code class="language-bash">cat &gt; /etc/udev/rules.d/99-i915-vf-vfio.rules &lt;&lt;'EOF'
# 把核显 VF (00:02.1 - 00:02.4) 绑定到 vfio-pci，PF (00:02.0) 保持 i915
ACTION=="add", SUBSYSTEM=="pci", KERNEL=="0000:00:02.[1-4]", ATTR{vendor}=="0x8086", ATTR{device}=="0x7d67", DRIVER!="vfio-pci", RUN+="/bin/sh -c 'echo $kernel &gt; /sys/bus/pci/devices/$kernel/driver/unbind; echo vfio-pci &gt; /sys/bus/pci/devices/$kernel/driver_override; modprobe vfio-pci; echo $kernel &gt; /sys/bus/pci/drivers/vfio-pci/bind'"
EOF

update-initramfs -u
</code></pre>
<h3>步骤 6：重启并验证</h3>
<pre><code class="language-bash">reboot
</code></pre>
<p dir="auto">重启后执行：</p>
<pre><code class="language-bash"># 1) 应看到 PF + 4 个 VF
lspci | grep -i vga
# 期望：00:02.0（PF）+ 00:02.1 / 00:02.2 / 00:02.3 / 00:02.4

# 2) VF 数量
cat /sys/bus/pci/devices/0000:00:02.0/sriov_numvfs     # 期望 4

# 3) 驱动归属：PF 是 i915，VF 是 vfio-pci
lspci -nnk -s 00:02

# 4) xe 应已不加载
lsmod | grep -E '^xe ' ; echo "（无输出 = 已成功屏蔽）"

# 5) GuC 应正常
dmesg | grep -iE 'guc|sriov' | tail -20

# 6) 宿主上不应出现 VF 的渲染节点
ls /dev/dri/
# 期望只有 card0 和 renderD128；若出现 renderD130+ 说明 VF 未成功屏蔽
</code></pre>
<p dir="auto"><strong>第 3 步的期望输出形态：</strong></p>
<pre><code>00:02.0 VGA compatible controller: Intel Corporation Arrow Lake-S [Intel Graphics] (rev 06)
        Kernel driver in use: i915          ← PF 仍是 i915
00:02.1 ...  Kernel driver in use: vfio-pci  ← VF 归 vfio
00:02.2 ...  Kernel driver in use: vfio-pci
00:02.3 ...  Kernel driver in use: vfio-pci
00:02.4 ...  Kernel driver in use: vfio-pci
</code></pre>
<h3>步骤 7：把 VF 分配给虚拟机</h3>
<p dir="auto">在 PVE Web 界面，对<strong>每一台</strong>要用的 VM：</p>
<ol>
<li><strong>硬件 → 添加 → PCI 设备</strong></li>
<li><strong>Raw Device</strong> 选择对应的 VF，例如 <code>0000:00:02.1</code></li>
<li>勾选 <strong>PCI-Express</strong></li>
<li><strong>不要</strong>勾选 "Primary GPU"；显示（Display）保持 <strong>virtio-gpu</strong> 或 <strong>SPICE</strong></li>
<li>一台 VM 只给一个 VF，四个 VF 给四台 VM</li>
</ol>
<blockquote>
<p dir="auto"><strong>VF 只做渲染/编解码，不驱动物理 HDMI/DP 输出。</strong> 显示走 virtio-gpu + SPICE/RDP/noVNC，这正是 Intel vGPU 云桌面的标准用法。</p>
</blockquote>
<h3>步骤 8：guest 内配置</h3>
<p dir="auto"><strong>DKMS 模块必须同时装在宿主机和 guest 里</strong>（项目 README 明确要求："You need to install this dkms module in both host and guest!"）。</p>
<p dir="auto">以 Ubuntu 24.04 guest 为例（本机的 VM 102 内核 <code>7.0.0-31-generic</code>，同样落在 6.17–7.1 支持区间）：</p>
<pre><code class="language-bash">sudo apt update
sudo apt install -y build-essential dkms "linux-headers-$(uname -r)" wget pciutils

# 安装同一个 deb
wget -O /tmp/i915-sriov-dkms_2026.08.12.1_amd64.deb \
  "https://github.com/strongtz/i915-sriov-dkms/releases/download/2026.08.12.1/i915-sriov-dkms_2026.08.12.1_amd64.deb"
sudo dpkg -i /tmp/i915-sriov-dkms_2026.08.12.1_amd64.deb
sudo dkms status

# guest 里不需要也不应该设 max_vfs（那是 PF 侧参数）
sudo sed -i 's/^GRUB_CMDLINE_LINUX_DEFAULT="/GRUB_CMDLINE_LINUX_DEFAULT="i915.enable_guc=3 module_blacklist=xe /' /etc/default/grub
sudo update-grub
sudo update-initramfs -u -k all
sudo reboot
</code></pre>
<p dir="auto">guest 内验证：</p>
<pre><code class="language-bash">ls -l /dev/dri                       # 期望出现 renderD128
sudo apt install -y vainfo intel-gpu-tools ffmpeg intel-media-va-driver-non-free
vainfo --display drm --device /dev/dri/renderD128
# 期望看到 H.264 / HEVC / VP9 / AV1 的 decode 入口

# FFmpeg 硬解冒烟测试（HEVC）
ffmpeg -hide_banner \
  -init_hw_device vaapi=va:/dev/dri/renderD128 -filter_hw_device va \
  -f lavfi -i testsrc2=size=1920x1080:rate=30 \
  -vf 'format=nv12,hwupload' -c:v hevc_vaapi -frames:v 120 -f null -
</code></pre>
<hr />
<h2>五、验证清单</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>#</th>
<th>检查项</th>
<th>命令（位置）</th>
<th>期望结果</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>DKMS 编译成功</td>
<td><code>dkms status</code>（宿主）</td>
<td><code>i915-sriov-dkms/2026.08.12.1, 7.0.14-16-pve: installed</code></td>
</tr>
<tr>
<td>2</td>
<td>xe 已屏蔽</td>
<td><code>lsmod \| grep '^xe '</code>（宿主）</td>
<td>无输出</td>
</tr>
<tr>
<td>3</td>
<td>VF 数量</td>
<td><code>cat .../sriov_numvfs</code>（宿主）</td>
<td><code>4</code></td>
</tr>
<tr>
<td>4</td>
<td>PF 归 i915</td>
<td><code>lspci -nnk -s 00:02.0</code>（宿主）</td>
<td><code>Kernel driver in use: i915</code></td>
</tr>
<tr>
<td>5</td>
<td>VF 归 vfio</td>
<td><code>lspci -nnk -s 00:02.1</code>（宿主）</td>
<td><code>Kernel driver in use: vfio-pci</code></td>
</tr>
<tr>
<td>6</td>
<td>宿主无 VF 渲染节点</td>
<td><code>ls /dev/dri/</code>（宿主）</td>
<td>只有 <code>card0</code> / <code>renderD128</code></td>
</tr>
<tr>
<td>7</td>
<td>GuC 正常</td>
<td><code>dmesg \| grep -i guc</code>（宿主）</td>
<td>无 firmware 加载失败</td>
</tr>
<tr>
<td>8</td>
<td>guest 看到设备</td>
<td><code>ls -l /dev/dri</code>（guest）</td>
<td><code>renderD128</code> 存在</td>
</tr>
<tr>
<td>9</td>
<td>硬解可用</td>
<td><code>vainfo --display drm ...</code>（guest）</td>
<td>列出 H.264/HEVC/VP9/AV1</td>
</tr>
<tr>
<td>10</td>
<td>多 VM 并行</td>
<td>四台 VM 同时转码</td>
<td>均正常，无掉卡</td>
</tr>
</tbody>
</table>
<hr />
<h2>六、风险与注意事项</h2>
<h3>6.1 实验性方案</h3>
<p dir="auto">DKMS 项目自己的声明是 <strong>"highly experimental"</strong>、"use it at your own risk"。走这条路意味着：</p>
<ul>
<li>不受 Intel 官方支持；</li>
<li>可能遇到稳定性问题。报 "driver not bound / 无 VF"。</li>
</ul>
<h3>6.2 内核升级会让模块失效</h3>
<p dir="auto"><strong>每次 PVE 升级内核后，必须重装/重编译 DKMS 模块，否则核显会退回内置驱动、VF 全部消失。</strong></p>
<pre><code class="language-bash"># 升级内核后
dkms status                                  # 检查是否已为新内核构建
apt install -y proxmox-headers-$(uname -r)   # 装新内核头文件
dkms autoinstall                             # 或重装 deb
</code></pre>
<p dir="auto">建议<strong>固定当前内核</strong>直到确认稳定，或在升级流程里加上 <code>dkms autoinstall</code>。</p>
<h3>6.3 四个 VF 共享同一颗物理核显</h3>
<p dir="auto">这是<strong>最重要的一条性能预期管理</strong>：4 个 VF 并非 4 颗独立显卡，它们共享同一组执行单元（EU）和媒体引擎（VDBOX）。</p>
<ul>
<li>4 台 VM <strong>同时</strong>重度转码会互相争抢，性能是非线性下降的；</li>
<li>Intel 的媒体引擎在 VF 之间的隔离并不完全，高并发时可能出现个别任务变慢；</li>
<li>轻中度办公/学习场景（偶尔看视频、视频会议硬解）完全够用；</li>
<li><strong>不要预期"4 路 4K 同时转码"能线性扩展。</strong></li>
</ul>
<h3>6.4 绝对不要把 PF 直通给 VM</h3>
<p dir="auto"><code>00:02.0</code>（PF）<strong>必须留在宿主机</strong>。把 PF 直通给任何 VM 会导致<strong>其余所有 VF 一起崩溃</strong>。只直通 <code>00:02.1</code> ~ <code>00:02.4</code>。</p>
<h3>6.5 不要覆盖现有的 vfio.conf</h3>
<p dir="auto">你的 <code>/etc/modprobe.d/vfio.conf</code> 里有 R9700 的 <code>ids=1002:7551,1002:ab40</code>。步骤 5 新建的是 <code>/etc/modules-load.d/vfio.conf</code>（不同目录、不同用途），<strong>不要用重定向覆盖 <code>/etc/modprobe.d/vfio.conf</code></strong>，否则 R9700 直通会失效。</p>
<h3>6.6 与现有 R9700 直通共存</h3>
<p dir="auto">两者互不冲突：R9700 走 <code>04:00.0</code> 的 vfio-pci，核显 PF 走 <code>00:02.0</code> 的 i915。但<strong>修改后务必回归验证 VM 102 能正常启动、<code>rocm-smi</code> 能看到 R9700</strong>。</p>
]]></description><link>https://lcz.me/topic/1634</link><generator>RSS for Node</generator><lastBuildDate>Wed, 23 Sep 2026 03:26:47 GMT</lastBuildDate><atom:link href="https://lcz.me/topic/1634.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 11 Sep 2026 18:25:31 GMT</pubDate><ttl>60</ttl></channel></rss>