You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何指定SLURM作业从固定节点启动并跨多节点运行

解决SLURM指定软件启动节点的问题

核心问题

SLURM默认会对--nodelist中的节点按名称排序,导致你指定的头节点hpc-c18可能不是第一个启动节点,触发软件许可限制。

解决方案

方法1:用--order=preserve保持节点顺序

在srun命令中添加--order=preserve参数,强制SLURM遵循你指定的节点顺序,这样第一个节点hpc-c18会被用作主进程启动节点。

修改后的脚本关键部分:

srun --nodelist=hpc-c18,hpc-c17,hpc-c16 --order=preserve --nodes=3 panx -y -hf hosts.txt -np 3 -n 64 CantileverTestLarge.in

方法2:拆分任务绑定指定节点

如果方法1不生效,可以明确指定主任务运行在hpc-c18,其余任务分配到其他节点:

# 在hpc-c18启动主进程
srun --nodelist=hpc-c18 --ntasks=1 panx -y -hf hosts.txt -np 3 -n 64 CantileverTestLarge.in &
# 在剩余节点启动辅助任务
srun --nodelist=hpc-c17,hpc-c16 --ntasks=2 panx -y -hf hosts.txt -np 3 -n 64 CantileverTestLarge.in
wait

注:需根据PanX的实际运行要求调整主辅进程的启动逻辑。

方法3:调整SBATCH节点顺序+任务分配策略

在SBATCH参数中将hpc-c18放在--nodelist首位,再用--distribution=block确保主任务分配到第一个节点:

#SBATCH --nodelist=hpc-c18,hpc-c17,hpc-c16  # 将hpc-c18放在最前面
...
srun --distribution=block --nodes=3 panx -y -hf hosts.txt -np 3 -n 64 CantileverTestLarge.in

--distribution=block会按节点顺序依次分配任务,第一个节点优先承载主任务。

完整修改脚本(推荐方法1)

#!/bin/bash

#SBATCH --job-name=Cantilever 
#SBATCH --output=output.txt 
#SBATCH --error=error.txt 
#SBATCH --nodes=3 
#SBATCH --ntasks-per-node=1 
#SBATCH --cpus-per-task=64             # Number of CPU cores on each node
#SBATCH --nodelist=hpc-c18,hpc-c17,hpc-c16      # PanX must be run on c18

echo "Running Cantilever test with PanX"

module load PanX

srun --nodelist=hpc-c18,hpc-c17,hpc-c16 --order=preserve --nodes=3 panx -y -hf hosts.txt -np 3 -n 64 CantileverTestLarge.in

内容的提问来源于stack exchange,提问作者cknott

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.11 22:12:41