sbatch脚本编写?gres资源申请?Slurm的sbatch脚本编写?gres资源申请?
sbatch 是 Slurm 的批处理提交命令,脚本中通过 #SBATCH directive 指定资源与行为。常用项:--job-name、--partition、--nodes/--ntasks-per-node、--cpus-per-task、--time、--output/--error;GPU 通过 gres 申请。脚本体为实际要执行的命令(如 srun 启动 MPI、或直接跑 Python)。
gres(Generic Resource):在 Slurm 中表示 GPU、FPGA 等设备。典型写法:#SBATCH --gres=gpu:2(2 块任意 GPU)、#SBATCH --gres=gpu:a100:4(4 块 A100)。需集群配置 GresTypes=gpu 及每节点 Gres=gpu:8 等。申请后任务内通过 CUDA_VISIBLE_DEVICES(由 Slurm 自动设置)使用对应 GPU。
srun 做多进程/多节点时,通常每个 task 对应一进程;配合 --gres 保证每进程可见的 GPU 与 task 绑定。超时用 --time 避免长占;大作业用 --exclusive 独占节点时可减少干扰。生产环境常把 partition、account、qos 等写进脚本或通过环境/模板注入。#SBATCH 指定 partition、nodes、cpus、time、output;GPU 用 --gres=gpu[:type]:数量。| 返回模块 | 返回总览 |