AMD ROCm 安装文档的 RHEL 版本选择器解析:从选择器指令到 dnf 安装落地
【免费下载链接】legacy-rocm-buildAMD ROCm™ Software - GitHub Home项目地址: https://gitcode.com/GitHub_Trending/ro/legacy-rocm-build
导读
本文围绕 legacy-rocm-build 仓库中驱动 ROCm 安装文档交互式体验的 RHEL 版本选择器(docs/install/include/rhel-ver-selector.rst)展开,逐层拆解它的 RST 指令结构、与 GPU/OS 选择器的联动逻辑,以及它在 RHEL 8/9/10 上完成 ROCm 安装的完整落地链路。读完本文,你将掌握 ROCm 文档如何用selector/selector-option/selected指令把"RHEL 版本"与"AMD GPU 型号"绑定,也能直接照抄仓库中的amdgpu-install下载、rocm.repo注册与dnf install amdrocm7.14全套命令,在 RHEL 系统上完成 ROCm 部署。
一、选择器在 ROCm 安装文档中的位置
ROCm 的安装主页面 docs/install/rocm.rst 是一张"向导式"页面:用户在页面上一层层选择设备家族(fam)→ GPU 型号(gpu)→ 操作系统(os)→ 安装方法(i)→ 发行版小版本(如 rhel-ver),页面内容随之动态收缩,最终只展示与当前选择匹配的安装命令。
这一连串 include 指令在 rocm.rst 第 34-56 行 中按固定顺序被拼装:
.. include:: ./include/fam-multi-arch-selector.rst .. include:: ./include/gpu-selector.rst .. include:: ./include/os-selector.rst .. include:: ./include/ror-gpu-selector.rst .. include:: ./include/ubuntu-ver-selector.rst .. include:: ./include/debian-ver-selector.rst .. include:: ./include/rhel-ver-selector.rst .. include:: ./include/oracle-linux-ver-selector.rst .. include:: ./include/rocky-linux-ver-selector.rst .. include:: ./include/sles-ver-selector.rst .. include:: ./include/windows-ver-selector.rst .. include:: ./include/install-method-selector.rstrhel-ver-selector.rst排在 OS 选择器之后,承担"当用户选定 RHEL 后,进一步选择 RHEL 具体版本"的职责;它与 ubuntu-ver-selector.rst、debian-ver-selector.rst 等文件是同一套模板在不同发行版上的平行实例。
页面顶部的元信息(rocm.rst 第 1-10 行)还通过:selector-toc2: Installation environment为该页挂接了一个专属的"安装环境"侧边栏 TOC,说明选择器不仅控制正文内容,还参与页面导航结构。
二、RHEL 版本选择器的指令结构逐段解析
2.1 外层条件容器:.. selected:: os=rhel
整个文件的第一行.. selected:: os=rhel把 RHEL 版本选择器整体包裹在一个条件容器中:只有当用户在上一级的 Linux 发行版选择器(os-selector.rst)中选中RHEL(Red Hat Enterprise Linux)时,这一组版本选项才会被渲染出来。
在 os-selector.rst 中可以看到 RHEL 是各 GPU 场景下的通用选项,例如对gpu=mi355x gpu=mi350x gpu=mi325x场景,RHEL 的:toc-label: Red Hat Enterprise Linux与 Ubuntu、Debian、Oracle Linux、SLES 并列展示(os-selector.rst 第 5-29 行)。
2.2 选择器主体:.. selector:: RHEL version
.. selector:: RHEL version :key: rhel-ver :show-cond: fam=instinct fam=radeon fam=all.. selector:: RHEL version:声明一个名为 "RHEL version" 的选择器组,标题文本就是括号内的第一参数。从实现上看,它会被渲染成一个带role="radiogroup"语义的分组(见下文第三节)。:key: rhel-ver:为该选择器命名一个键rhel-ver,这是后续所有条件表达式(rhel-ver=10.2等)引用的标识符。源码 utils.py 中的normalize_key会把键统一为小写、空格转下划线的规范形式。:show-cond: fam=instinct fam=radeon fam=all:声明该选择器仅在设备家族为 Instinct、Radeon 或 All 时显示,即 Ryzen APU 场景下不会出现 RHEL 版本选项(对应 os-selector.rst 中 Ryzen 场景没有 RHEL 选项的设计)。
2.3 版本选项:.. selector-option::
文件主体由 6 个 RHEL 版本构成:10.2、10.0、9.8、9.6、9.4、8.10,每个版本是一个selector-option,并用:show-cond:声明它面向哪些 GPU,用:width:控制其在栅格中的占位宽度。
面向主流 Instinct 数据中心的组合(width: 2)
这 6 个版本对以下 Instinct GPU 全量开放(rhel-ver-selector.rst 第 7-29 行):
.. selector-option:: 10.2 :show-cond: gpu=mi355x gpu=mi350x gpu=mi300x gpu=mi300a gpu=mi250x gpu=mi250 gpu=mi210 gpu=mi100 :width: 2- 10.2、10.0、9.8、9.6、9.4、8.10 全部可用;
- 覆盖 GPU:MI355X、MI350X、MI300X、MI300A、MI250X、MI250、MI210、MI100;
- 宽度为 Bootstrap 12 列栅格中的 2 列(每行可排 6 个版本按钮)。
MI350P 的组合(width: 4)
.. selector-option:: 10.2 :show-cond: gpu=mi350p :width: 4MI350P 只支持10.2、9.8、9.6三个版本,每个按钮占 4 列(rhel-ver-selector.rst 第 31-41 行)。
MI325X 的组合(width: 20%)
.. selector-option:: 10.2 :show-cond: gpu=mi325x :width: 20%MI325X 支持10.2、10.0、9.8、9.6、9.4五个版本(不含 8.10),每个按钮按 20% 宽度排版(rhel-ver-selector.rst 第 43-61 行)。
Radeon 系列的组合(width: 6)
.. selector-option:: 10.2 :show-cond: fam=radeon :width: 6fam=radeon场景只提供10.2、9.8两个版本,每个占 6 列(半行宽)(rhel-ver-selector.rst 第 63-69 行)。
"All" 通用组合(width: 2)
当用户在设备家族选择器中选择 "All" 时,fam=all分支开放全部 6 个版本:10.2、10.0、9.8、9.6、9.4、8.10,每个宽度 2 列(rhel-ver-selector.rst 第 71-92 行),与主流 Instinct 组合保持一致。
2.4 GPU × RHEL 版本支持矩阵(由 :show-cond: 归纳)
将上述条件归纳,得到 RHEL 版本选择器的完整支持矩阵:
| GPU / 设备家族 | 10.2 | 10.0 | 9.8 | 9.6 | 9.4 | 8.10 | 按钮宽度 |
|---|---|---|---|---|---|---|---|
| MI355X / MI350X / MI300X / MI300A / MI250X / MI250 / MI210 / MI100 | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | 2 列 |
| MI350P | ✔ | – | ✔ | ✔ | – | – | 4 列 |
| MI325X | ✔ | ✔ | ✔ | ✔ | ✔ | – | 20% |
| Radeon(fam=radeon) | ✔ | – | ✔ | – | – | – | 6 列 |
| All(fam=all) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | 2 列 |
说明:该矩阵完全由 rhel-ver-selector.rst 中各选项的
:show-cond:推导而来,是文档选择器层面的"版本可见性"声明,最终安装兼容性以 兼容性矩阵 为准。
三、选择器的底层实现原理(源码级)
selector/selector-option/selected并非 reStructuredText 内建指令,而是由 ROCm 文档自研的 Sphinx 扩展提供,实现在 docs/extension/rocm_docs_custom/selector/init.py。
3.1 三个核心节点
| 指令 | 节点类 | 职责 |
|---|---|---|
.. selector::/.. selector-dropdown:: | SelectorGroup | 渲染一行 radio 分组或下拉框(<div role="radiogroup">或<select>) |
.. selector-option:: | SelectorOption | 渲染一个可点击的 radio 瓦片(<div role="radio">) |
.. selected::/.. selected-content:: | SelectedContent | 条件内容容器,按data-show-cond控制显隐 |
在setup()(selector/init.py 第 465-493 行)中,这些节点与指令被注册,并挂接了env-purge-doc、env-merge-info、env-updated、html-page-context四个事件,分别负责清理选择器页面集合、跨文档合并、注入侧边栏和注入 TOC2 上下文。
3.2show-cond条件如何变成前端逻辑
rhel-ver-selector.rst中大量出现的:show-cond: gpu=mi355x gpu=mi350x ...会被 utils.py 的 kv_to_data_attr 解析为 HTML 的data-show-cond属性——把空格分隔的key=value列表转成 JSON 对象,例如:
gpu=mi355x gpu=mi350x gpu=mi300x → >.. selector-option:: AMD Instinct MI355X (gfx950) :value: mi355x gfx=gfx950SelectorOptionDirective会把value按空格拆词(selector/init.py 第 357-373 行):第一个不带=的 token(mi355x)是该选项自身的值,其余gfx=gfx950形式的 token 则写入data-selector-extra-bindings,在选中该 GPU 时同步绑定gfx=gfx950——这个gfx键随后被安装步骤用来选择架构专属的 ROCm 包(如amdrocm7.14-gfx950)。
四、在 RHEL 上安装 ROCm 的完整落地流程
选择器的终点是 docs/install/include/200-install.rst 中按os=rhel+rhel-ver=*条件展开的安装步骤。以下是仓库中为 RHEL 准备的完整命令链。
4.1 前置注意
200-install.rst 第 10-14 行 对 RHEL 10.0 / 9.6 / 9.4 / 8.10(以及选择器未列出的 10.2)场景给出统一提示:
如果系统已安装 ROCm 7.2.4 或更早版本,请先卸载旧版 ROCm 再继续安装。
4.2 方式一:安装 amdgpu-install 脚本(图形/计算混合场景)
在w=graphics场景下,需要先下载并安装amdgpu-install驱动安装脚本(200-install.rst 第 83-125 行)。每个 RHEL 版本对应一个独立的 RPM:
| RHEL 版本 | 命令 |
|---|---|
| 10.2 | wget https://repo.radeon.com/amdgpu-install/31.40.1/rhel/10.2/amdgpu-install-31.40.1.314001-1.el10.noarch.rpmsudo dnf install ./amdgpu-install-31.40.1.314001-1.el10.noarch.rpm |
| 10.0 | wget https://repo.radeon.com/amdgpu-install/31.40.1/rhel/10.0/amdgpu-install-31.40.1.314001-1.el10.noarch.rpmsudo dnf install ./amdgpu-install-31.40.1.314001-1.el10.noarch.rpm |
| 9.8 | wget https://repo.radeon.com/amdgpu-install/31.40.1/rhel/9.8/amdgpu-install-31.40.1.314001-1.el9.noarch.rpmsudo dnf install ./amdgpu-install-31.40.1.314001-1.el9.noarch.rpm |
| 9.6 | wget https://repo.radeon.com/amdgpu-install/31.40.1/rhel/9.6/amdgpu-install-31.40.1.314001-1.el9.noarch.rpmsudo dnf install ./amdgpu-install-31.40.1.314001-1.el9.noarch.rpm |
| 9.4 | wget https://repo.radeon.com/amdgpu-install/31.40.1/rhel/9.4/amdgpu-install-31.40.1.314001-1.el9.noarch.rpmsudo dnf install ./amdgpu-install-31.40.1.314001-1.el9.noarch.rpm |
| 8.10 | wget https://repo.radeon.com/amdgpu-install/31.40.1/rhel/8.10/amdgpu-install-31.40.1.314001-1.el8.noarch.rpmsudo dnf install ./amdgpu-install-31.40.1.314001-1.el8.noarch.rpm |
注意 RPM 文件名中的小版本后缀规律:RHEL 10.x 对应el10、9.x 对应el9、8.10 对应el8。
4.3 方式二:注册 ROCm 官方仓库(dnf 安装核心包)
在i=pkgman(包管理器)场景下,RHEL 需要手动注册 ROCm 仓库(200-install.rst 第 467-572 行)。RHEL 10.2 / 10.0 分支的配置如下:
sudo tee /etc/yum.repos.d/rocm.repo <<EOF [rocm] name=ROCm 7.14.0 baseurl=https://repo.amd.com/rocm/packages-multi-arch/rhel10/x86_64 enabled=1 gpgcheck=1 gpgkey=https://repo.amd.com/rocm/packages-multi-arch/gpg/rocm.gpg priority=50 EOF sudo dnf clean allRHEL 9.8 / 9.6 / 9.4 分支将baseurl换成.../rhel9/x86_64,RHEL 8.10 分支换成.../rhel8/x86_64(200-install.rst 第 506-572 行)。各字段含义:
name=ROCm 7.14.0:仓库显示名,对应当前文档所描述的 ROCm 7.14.0 版本;baseurl:按大版本(rhel8/rhel9/rhel10)区分的多架构 x86_64 仓库地址;gpgcheck=1+gpgkey:启用 GPG 签名校验,签名公钥来自官方rocm.gpg;priority=50:设置 dnf 优先级,避免与其他仓库的包产生冲突。
4.4 安装 ROCm 核心包
注册仓库后,安装命令同样按os=rhel os=oracle-linux os=rocky-linux分组(200-install.rst 第 897-997 行):
# 安装通用核心包(fam=all 场景) sudo dnf install amdrocm7.14 # 或按 GPU 架构(gfx)安装专属包,例如: sudo dnf install amdrocm7.14-gfx950 # MI355X / MI350X / MI350P sudo dnf install amdrocm7.14-gfx942 # MI325X / MI300X / MI300A sudo dnf install amdrocm7.14-gfx90a # MI250X / MI250 / MI210 sudo dnf install amdrocm7.14-gfx908 # MI100这里正是第三节提到的:value: mi355x gfx=gfx950复合绑定发挥作用的地方:用户在 GPU 选择器选中具体型号后,页面会自动切换到对应的amdrocm7.14-gfxXXX架构包命令。包名中的gfx编号与 GPU 架构一一对应,避免安装不匹配的二进制。
4.5 驱动安装与重启
若使用 runfile 安装器方式,内核驱动通过以下命令安装(200-install.rst 第 264-266 行):
bash rocm-installer-7.14.0-7.run deps=install amdgpu安装 amdgpu 驱动后需要重启系统。包管理器(pkgman)方式下,Instinct / Radeon 设备的 amdgpu 驱动安装指引指向 AMD Instinct 数据中心的原生安装文档;Ryzen APU 场景则要求使用系统内置(inbox)内核驱动。
五、选择器之间的联动关系图
从用户视角,安装页面的交互是一个逐级收敛的决策链:
设备家族 (fam) → GPU 型号 (gpu) → 操作系统 (os) → RHEL 版本 (rhel-ver) → 安装方法 (i) │ │ │ │ │ │ :value: 附加绑定 │ :show-cond: 精确过滤 │ │ gfx=gfx950 等 │ (GPU×版本支持矩阵) │ │ │ │ └──────────── 最终输出 os=rhel + rhel-ver=X + gfx=Y 对应的安装命令 ────────────┘fam-multi-arch-selector.rst定义设备家族与用途(w=compute/w=graphics);gpu-selector.rst用:value:的复合绑定同时设置gpu与gfx键;os-selector.rst在 Linux 发行版层面决定是否出现 RHEL 选项;rhel-ver-selector.rst(本文主体)用:show-cond:将 RHEL 版本收缩到当前 GPU 真正支持的范围;install-method-selector.rst决定最终走pkgman/pip/tar/runfile哪条安装路径。
上述所有键值都通过data-*属性注入页面 DOM,由 selector.js 统一驱动,构成一套"无刷新、纯前端"的条件文档系统。
六、快速查阅索引
- RHEL 版本选择器定义:docs/install/include/rhel-ver-selector.rst
- 安装主页面与 include 链:docs/install/rocm.rst
- 操作系统(发行版)选择器:docs/install/include/os-selector.rst
- GPU 型号选择器(含
gfx绑定):docs/install/include/gpu-selector.rst - 设备家族与用途选择器:docs/install/include/fam-multi-arch-selector.rst
- RHEL 安装步骤(amdgpu-install / rocm.repo / dnf install):docs/install/include/200-install.rst
- 选择器 Sphinx 扩展实现:docs/extension/rocm_docs_custom/selector/init.py
show-cond解析工具:docs/extension/rocm_docs_custom/utils.py- 前端交互脚本:docs/extension/rocm_docs_custom/selector/static/selector.js
结语
rhel-ver-selector.rst虽然只是一个不足百行的 RST 片段,却是 ROCm 安装文档"按需展示"体系中的关键一环:它通过selected+selector+selector-option三层指令,把 RHEL 10.2/10.0/9.8/9.6/9.4/8.10 与从 MI100 到 MI355X 的每一块 AMD GPU 精确配对,再配合200-install.rst中的仓库注册与dnf install命令,最终让用户"选什么、装什么"始终一致。理解了这一机制,你不仅能在 RHEL 上正确安装 ROCm,也能看懂整个 ROCm 文档选择器体系的构建范式——这套模式同样被 Ubuntu、Debian、Oracle Linux、Rocky Linux、SLES、Windows 等平行选择器复用。
【免费下载链接】legacy-rocm-buildAMD ROCm™ Software - GitHub Home项目地址: https://gitcode.com/GitHub_Trending/ro/legacy-rocm-build
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考