101: How to submit Slurm batch jobs
Introduction on how to submit the job to the Slurm cluster
Below is a sample Slurm script for running a Python code:
You python script example1.py
and the Slurm submission script example1.slurm
Note that,
For
--qos
, you should check which qos that you are assigned. You can check by usingsacctmgr show assoc format=cluster,user,qos
QoS includes
cu_hpc, cu_htc, cu_math, cu_long, cu_student, escience
For
--partition
, you can choosecpu
orcpugpu
for all QoS, except for cu_math (usemath
partition).See detail of QoS and partition here.
You can also use other shells if want, not limited to bash. See an example of tcsh/csh in the CMSSW example.
To submit the job, you use sbatch
You will see
To check if your job is in which state
In the ST column, R is Running, PD is pending.
Your output should look like
With the Slurm output, you see that your job is running on the same directory that you submit the job (e.g. /work/home/your_user_name/slurm/example1
. This is not recommended. You should move the job to run on $TMPDIR
(or $SLURM_SUBMIT_DIR
) and copy the output back when the job is done. Here is an example of modified example1.slurm
to run on $TMPDIR
and copy test.log
(output of python script) back to your submission directory. The $TMPDIR
will be deleted automatically after the job is done.
Last updated