第 8 章 使用 RHEL 系统角色在 Azure 上部署 HPC 集群
Microsoft Azure 上的高性能计算(HPC)工作负载需要特殊配置来获得最佳性能和可扩展性。HPC RHEL 系统角色使用特定于 HPC 的优化来自动配置 RHEL 镜像,包括 InfiniBand 支持、性能调优和所需的库。
配置启用了 HPC 的镜像后,您可以对虚拟机进行常规化,并在 Azure Compute Gallery 中创建可重复使用的镜像版本。这些镜像作为使用 Azure CycleCloud 在 Microsoft Azure 上部署 HPC 集群的基础,它是一个与 Slurm 工作负载管理器集成的集群编配工具来调度和管理计算作业。环境模块提供了一个灵活的框架,用于管理多个软件版本及其在 HPC 集群节点之间的依赖项。
8.1. 使用 HPC RHEL 系统角色为 HPC 配置 RHEL Azure 虚拟机 复制链接链接已复制到粘贴板!
要在自定义 Red Hat Enterprise Linux (RHEL)镜像上配置高性能计算(HPC) RHEL 系统角色,您可以使用 cloud-init 实用程序。使用 cloud-init 时,您可以自动配置 Ansible 集合,并在 Microsoft Azure 上运行 Ansible playbook。
使用以下方法之一在自定义 RHEL 镜像上配置 HPC RHEL 系统角色。
8.1.1. 使用 Azure Portal 配置 RHEL HPC 虚拟机 复制链接链接已复制到粘贴板!
通过将 Ansible 与 ansible-core 实用程序搭配使用,您可以在镜像构建过程中应用 RHEL 系统角色来自动配置 Azure 的自定义 RHEL 镜像。cloud-init 等工具嵌入了高性能计算(HPC) RHEL 系统角色配置,以在 Azure 中部署之前创建和配置 HPC RHEL 镜像。
先决条件
- 您有一个活跃的 Azure 云订阅。
流程
- 进入 Azure 控制台。
-
点 Virtual Machines
Create Virtual Machine。 从 Basics 选项卡中为虚拟机选择以下配置:
- 在 Virtual machine name 字段中输入您的虚拟机名称。
- 安全类型 :标准
-
Image
See All Images Search for Red Hat Enterprise Linux (RHEL) for High Computing (HPC) on Azure Select Red Hat Enterprise Linux for HPC 9.6 VM - x64 Gen2 - VM 架构: x64
大小 : Standard_NC4as_T4_v3 - 4 vcpus, 28 GiB 内存
注意要获得最佳性能,请只使用 GPU 优化的虚拟机,如 NC 和 ND 系列。详情请参阅 Azure 中的虚拟机大小。
进入 Advanced 选项卡,在 Custom data 字段中输入以下详情:
#cloud-config #Please check RHEL HPC Ansible system role documentation for all available options write_files: - path: /root/hpc_full_install.yaml permissions: 644 content: | --- - name: Install and configure HPC hosts: localhost become: true vars: hpc_reboot_ok: false hpc_update_all_packages: true hpc_manage_firewall: true roles: - redhat.rhel_system_roles.hpc - path: /etc/dnf/azure-rhel9-eus.config permissions: 644 content: | [rhui-microsoft-azure-rhel9] name=Microsoft Azure RPMs for Red Hat Enterprise Linux 9 (rhel9-eus) baseurl=https://rhui4-1.microsoft.com/pulp/repos/unprotected/microsoft-azure-rhel9-eus enabled=1 gpgcheck=1 sslverify=1 gpgkey=/etc/pki/rpm-gpg/RPM-GPG-KEY-microsoft-azure-release - path: /etc/dnf/vars/releasever permissions: 644 content: | 9.6 # Run custom commands runcmd: # lock VM to RHEL9.6 and enable EUS channels # https://learn.microsoft.com/en-us/azure/virtual-machines/workloads/redhat/redhat-rhui - dnf --assumeyes --disablerepo='*' remove "rhui-azure-rhel9" - dnf --assumeyes --config /etc/dnf/azure-rhel9-eus.config install rhui-azure-rhel9-eus - dnf --assumeyes clean all - dnf --assumeyes install rhel-system-roles- 点 Review + create 按钮创建带有给定配置的虚拟机。
- 在 Azure 控制台中,检查虚拟机是否已成功部署并可使用。
- 点 Go to resource 按钮。
- 复制公共 IP 地址。
- 在 Azure 控制台中,检查虚拟机是否正在运行。
连接到虚拟机:
$ ssh -i ~/.ssh/azure_hpc <example_azureuser>@<192.0.2.101>检查虚拟机状态:
$ sudo cloud-init status --wait准备就绪后,运行 HPC RHEL 系统角色:
$ sudo ANSIBLE_LOG_PATH=/var/log/ansible_hpc_full_install.log ansible-playbook /root/hpc_full_install.yaml --verbose重启虚拟机。
重要等待初始重启完成,因为 HPC RHEL 系统角色配置在此阶段完成。
验证
通过 SSH 连接到虚拟机:
$ ssh -i <example_private_key.pem> <example_azureuser>@<192.0.2.101>验证安装的软件包列表:
$ sudo dnf list installed| grep -i -E 'nvidia-driver|cuda-toolkit|nccl|fabric-manager|rdma|openmpi'cuda-toolkit-12-9.x86_64 12.9.1-1 @nvidia-cuda cuda-toolkit-12-9-config-common.noarch 12.9.79.1 @nvidia-cuda cuda-toolkit-12-config-common.noarch 12.9.79.1 @nvidia-cuda cuda-toolkit-config-common.noarch 12.9.79.1 @nvidia-cuda libnccl.x86_64 2.27.5-1+cuda12.9 @nvidia-cuda libnccl-devel.x86_64 2.27.5-1+cuda12.9 @nvidia-cuda librdma.x86_64 54.0.1-e19 @rhel-9-for-x86_64-baseos-rhui-rpms nvidia-driver.x86_64 3:575.57.08-1.e19 @nvidia-cuda nvidia-driver-cuda.x86_64 3:575.57.08-1.e19 @nvidia-cuda nvidia-driver-cuda-libs.x86_64 3:575.57.08-1.e19 @nvidia-cuda nvidia-driver-libs.x86_64 3:575.57.08-1.e19 @nvidia-cuda nvidia-fabric-manager.x86_64 575.57.08-1 @nvidia-cuda openmpi.x86_64 2:4.1.7-7.e19 @rhel-9-for-x86_64-appstream-rhui-rpms openmpi-devel.x86_64 2:4.1.7-7.e19 @rhel-9-for-x86_64-appstream-rhui-rpms rdma-core.x86_64 54.0.1-e19 @rhel-9-for-x86_64-baseos-rhui-rpms验证已安装的
Lmod环境模块:$ ml available-----------------------/usr/share/modulefiles------------------------ mpi/hpcx-2.24.1-pmix-4.2.9 mpi/openmpi-5.0.8-cuda12-gpu (L,D) mpi/hpcx-2.24.1 pmix/pmix-4.2.9 (L) mpi/openmpi-x86_64 ----------------/usr/share/lmod/lmod/modulefiles/Core---------------- lmod settarg其中:
-
l: Module is loaded -
D:默认模块
-
后续步骤
8.1.2. 使用 Azure CLI 配置 RHEL HPC 虚拟机 复制链接链接已复制到粘贴板!
通过将 Ansible 与 ansible-core 实用程序搭配使用,您可以在镜像构建过程中应用 RHEL 系统角色来自动配置自定义 Red Hat Enterprise Linux (RHEL)镜像。cloud-init 和 Azure CLI 等工具管理高性能计算(HPC) RHEL 系统角色,以在 Azure 中部署之前创建和配置 HPC RHEL 镜像。
先决条件
- 您有一个活跃的 Azure 云订阅。
流程
连接到 Azure 门户:
$ az login创建密钥对:
$ ssh-keygen -t ed25519 -b 3072 -C "<azureuser@hpc>" -f ~/.ssh/azure_hpc使用以下详情编辑
user-data.yml文件:$ vi user-data.yml#cloud-config # Please check RedHat HPC Ansible system role documentation for all available options write_files: - path: /root/hpc_full_install.yaml permissions: 644 content: | --- - name: Install and configure HPC hosts: localhost become: true vars: hpc_reboot_ok: false hpc_update_all_packages: true hpc_manage_firewall: true roles: - redhat.rhel_system_roles.hpc - path: /etc/dnf/azure-rhel9-eus.config permissions: 644 content: | [rhui-microsoft-azure-rhel9] name=Microsoft Azure RPMs for Red Hat Enterprise Linux 9 (rhel9-eus) baseurl=https://rhui4-1.microsoft.com/pulp/repos/unprotected/microsoft-azure-rhel9-eus enabled=1 gpgcheck=1 sslverify=1 gpgkey=/etc/pki/rpm-gpg/RPM-GPG-KEY-microsoft-azure-release - path: /etc/dnf/vars/releasever permissions: 644 content: | 9.6 # Run custom commands runcmd: # lock VM to RHEL9.6 and enable EUS channels # https://learn.microsoft.com/en-us/azure/virtual-machines/workloads/redhat/redhat-rhui - dnf --assumeyes --disablerepo='*' remove "rhui-azure-rhel9" - dnf --assumeyes --config /etc/dnf/azure-rhel9-eus.config install rhui-azure-rhel9-eus - dnf --assumeyes clean all - dnf --assumeyes install rhel-system-roles创建资源组:
$ az group create --name <example_vm_resource_group>为您的帐户选择并接受相关镜像的条款和条件:
对于北美(NA)或全球帐户,请使用:
$ az vm image terms accept --urn "redhat:rh-rhel-hpc:rh-rhel-hpc96:latest"对于欧洲、中东和非洲(EMEA)帐户,请使用:
$ az vm image terms accept --urn "redhat-limited:rh-rhel-hpc:rh-rhel-hpc96:latest"
根据上一步中指定的配置创建镜像:
$ az vm create \ --resource-group <example_vm_resource_group> \ --name <example_vm_name> \ --image <example_rhel_hpc_image_urn> \ --size <Standard_NC4as_T4_v3> \ --admin-username <example_azureuser> \ --ssh-key-values ~/.ssh/azure_hpc.pub \ --custom-data user-data.yaml \ --security-type Standard \ --public-ip-address-dns-name <example_vm_name>-$(openssl rand -hex 4) \ --tags owner=$USER project=hpc- 检查虚拟机是否在运行,检查 Azure 控制台。
通过 SSH 连接到虚拟机:
$ ssh -i ~/.ssh/azure_hpc <example_azureuser>@<192.0.2.101>检查虚拟机状态:
$ sudo cloud-init status --wait准备就绪后,运行 HPC RHEL 系统角色:
$ sudo ANSIBLE_LOG_PATH=/var/log/ansible_hpc_full_install.log ansible-playbook /root/hpc_full_install.yaml --verbose重启虚拟机。
重要等待初始重启完成,因为 HPC RHEL 系统角色配置在此阶段完成。
验证
通过 SSH 连接到虚拟机:
$ ssh -i <example_private_key.pem> <example_azureuser>@<192.0.2.101>验证安装的软件包列表:
$ sudo dnf list installed| grep -i -E 'nvidia-driver|cuda-toolkit|nccl|fabric-manager|rdma|openmpi'cuda-toolkit-12-9.x86_64 12.9.1-1 @nvidia-cuda cuda-toolkit-12-9-config-common.noarch 12.9.79.1 @nvidia-cuda cuda-toolkit-12-config-common.noarch 12.9.79.1 @nvidia-cuda cuda-toolkit-config-common.noarch 12.9.79.1 @nvidia-cuda libnccl.x86_64 2.27.5-1+cuda12.9 @nvidia-cuda libnccl-devel.x86_64 2.27.5-1+cuda12.9 @nvidia-cuda librdma.x86_64 54.0.1-e19 @rhel-9-for-x86_64-baseos-rhui-rpms nvidia-driver.x86_64 3:575.57.08-1.e19 @nvidia-cuda nvidia-driver-cuda.x86_64 3:575.57.08-1.e19 @nvidia-cuda nvidia-driver-cuda-libs.x86_64 3:575.57.08-1.e19 @nvidia-cuda nvidia-driver-libs.x86_64 3:575.57.08-1.e19 @nvidia-cuda nvidia-fabric-manager.x86_64 575.57.08-1 @nvidia-cuda openmpi.x86_64 2:4.1.7-7.e19 @rhel-9-for-x86_64-appstream-rhui-rpms openmpi-devel.x86_64 2:4.1.7-7.e19 @rhel-9-for-x86_64-appstream-rhui-rpms rdma-core.x86_64 54.0.1-e19 @rhel-9-for-x86_64-baseos-rhui-rpms验证已安装的
Lmod环境模块:$ ml available-----------------------/usr/share/modulefiles------------------------ mpi/hpcx-2.24.1-pmix-4.2.9 mpi/openmpi-5.0.8-cuda12-gpu (L,D) mpi/hpcx-2.24.1 pmix/pmix-4.2.9 (L) mpi/openmpi-x86_64 ----------------/usr/share/lmod/lmod/modulefiles/Core---------------- lmod settarg其中:
-
l: Module is loaded -
D:默认模块
-