top
福建省超级计算中心

sbatch:提交作业

sbatch

提交一个批脚本到作业调度系统中。

使用方式为sbatch [OPTIONS(0)...] [ : [OPTIONS(n)...]] script(0) [args(0)...]

常见参数

--help显示sbatch命令的使用帮助信息;
-A指定计费账户;
-D, --chdir=指定工作目录;
--get-user-env获取用户的环境变量;
--gres=使用gpu这类资源,如申请两块gpu则--gres=gpu:2
-J, --job-name=指定该作业的作业名;
--mail-type=指定状态发生时,发送邮件通知,有效种类为(NONE, BEGIN, END, FAIL, REQUEUE, ALL);
--mail-user=发送给对应邮箱;
-n, --ntasks=sbatch并不会执行任务,当需要申请相应的资源来运行脚本,默认情况下一个任务一个核心,--cpus-per-task参数可以修改该默认值;
-c, --cpus-per-task=每个任务所需要的核心数,默认为1;
--ntasks-per-node=每个节点的任务数,--ntasks参数的优先级高于该参数,如果使用--ntasks这个参数,那么将会变为每个节点最多运行的任务数;
-o, --output=输出文件,作业脚本中的输出将会输出到该文件;
-p, --partition=将作业提交到对应分区;
-q, --qos=指定QOS;
-t, --time=设置限定时间;

例子

1、提交一个作业,该作业提交到CPU分区上,共使用两个节点,每个节点4个核心,作业名为myFirstJob,以下为脚本的内容,脚本文件名为job.sh。

#!/bin/bash
#SBATCH -o job.%j.out
#SBATCH --partition=C032M0128G
#SBATCH --qos=low
#SBATCH -A hpcxxxxxx
#SBATCH -J myFirstJob
#SBATCH --get-user-env
#SBATCH --nodes=2
#SBATCH --ntasks-per-node=4
#SBATCH --mail-type=end
#SBATCH --mail-user=xxxx@pku.edu.cn
#SBATCH --time=120:00:00
srun hostname -s | sort -n >slurm.hosts
module load intel/2017.1
mpiicc -o hellompi.o hellompi.c
mpirun -n 8 -machinefile slurm.hosts ./hellompi.o
rm -rf slurm.hosts

提交作业

$ sbatch job.sh

返回


foot