User Tools

Site Tools


slurm_scripts

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
slurm_scripts [2020/01/29 18:58]
root created
slurm_scripts [2022/05/02 17:03] (current)
root created
Line 1: Line 1:
 ====Slurm Commands and Scripts==== ====Slurm Commands and Scripts====
-Basic torque/slurm commands are:+Basic slurm commands are:
 <csv> <csv>
-torque,                     slurm, +slurm, use 
-qsub,                       sbatch         ,       submit <job file> +sbatch         ,       submit <job file> 
-qsub -I   ,                  srun            ,      submit interactive job +srun            ,      submit interactive job 
-qstat  ,                     squeue           ,     list all queued jobs +squeue           ,     list all queued jobs 
-qstat -u rfeynman  ,         squeue -u rfeynman  ,  list queued jobs for user rfeynman +squeue -u rfeynman  ,  list queued jobs for user rfeynman 
-qdel        ,                scancel       ,        cancel <job#> +scancel       ,        cancel <job#> 
-shownodes -l -n;qstat -q ,   sinfo         ,        node status;list of queues+sinfo         ,        node status;list of queues
 </csv> </csv>
  
-A basic slurm script looks like:+A Torque compatibility layer also offers some torque commands such as ''qstat'' and ''qsub''.  A basic script in ''slurm'' looks like: 
 <code> <code>
 #!/bin/bash #!/bin/bash
Line 25: Line 26:
 mpirun -np $SLURM_NTASKS -machinefile /scratch/${SLURM_JOB_ID}/machinefile_${SLURM_JOB_ID} ./mympiexe -inputfile MA4um.mph -outputfile MA4um-output.mph mpirun -np $SLURM_NTASKS -machinefile /scratch/${SLURM_JOB_ID}/machinefile_${SLURM_JOB_ID} ./mympiexe -inputfile MA4um.mph -outputfile MA4um-output.mph
 </code> </code>
-and a little more complicated with file moving in and out of a scratch area:+ 
 +and a more complex script with file moving looks like: 
 + 
 <code> <code>
-pinnacle-l1:$ cat script.slurm 
 #!/bin/bash #!/bin/bash
 #SBATCH --job-name=espresso #SBATCH --job-name=espresso
Line 40: Line 43:
 cp *.in *UPF /scratch/$SLURM_JOB_ID cp *.in *UPF /scratch/$SLURM_JOB_ID
 cd /scratch/$SLURM_JOB_ID cd /scratch/$SLURM_JOB_ID
-mpirun -ppn 16 -hostfile /scratch/${SLURM_JOB_ID}/machinefile_${SLURM_JOB_ID} -genv OMP_NUM_THREADS 4 -genv MKL_NUM_THREADS 4 /share/apps/espresso/qe-6.1-intel-mkl-impi/bin/pw.x -npools 1 <ausurf.in+mpirun -ppn 16 -hostfile /scratch/${SLURM_JOB_ID}/machinefile_${SLURM_JOB_ID} -genv OMP_NUM_THREADS 2 \ /share/apps/espresso/qe-6.1-intel-mkl-impi/bin/pw.x -npools 1 <ausurf.in
 mv ausurf.log *mix* *wfc* *igk* $SLURM_SUBMIT_DIR/ mv ausurf.log *mix* *wfc* *igk* $SLURM_SUBMIT_DIR/
 pinnacle-l1:$ pinnacle-l1:$
 </code> </code>
 +
 +See also [ https://www.marquette.edu/high-performance-computing/pbs-to-slurm.php ] [ https://hpc.nih.gov/docs/pbs2slurm.html
 + ]
 +
 +
 +
 +
 +
 +
 +We have a conversion script **/share/apps/bin/pbs2slurm.sh** which should do 95% of the script conversion from old PBS scripts to SLURM scripts. Please report errors by the script so we can improve it. Normally it should be in your path and
 +<code>
 +pbs2slurm.sh <pbs-script-name>
 +</code>
 +will generate the conversion to stdout, thus save with
 +<code>
 +pbs2slurm.sh demoscriptpbs.sh > demoscriptslurm.sh
 +</code>
 +
 +==Notes:==
 +
 +Leading hash-bang /bin/sh or /bin/bash or /bin/tcsh is optional in torque, required in slurm, pbs2slurm.sh inserts it if not present\\
 +
 +Slurm date formats with days are "2-00:00:00" not "2:00:00:00" like Torque.  If invalid sbatch will use the partition default and srun will kick the job back.\\
 +
 +Slurm unlike Torque does not autogenerate an MPI machinefile/hostfile, so the job creates
 +<code>/scratch/${SLURM_JOB_ID}/machinefile_${SLURM_JOB_ID}</code>
 +The generated machinefile differs from torque machinefile in that it has 1 entry per host instead of ''ncores'' entry per host.
 +Slurm does define a variable with the total number of cores ''$SLURM_NTASKS'', good for most MPI jobs that use every core.
slurm_scripts.1580324288.txt.gz · Last modified: 2020/01/29 18:58 by root