Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: more removal of incorrect srun examples


Like sbatch, srun can be used to submit jobs under the SLURM scheduler. sbatch and srun even share many of the same options! However, srun is implemented a bit differently. You can use srun to create job steps (simply put srun in front of the commands you want to run) within an sbatch script, or to start an interactive session, or to submit job steps independent of sbatch. If . If srun is used within an sbatch script, it will use the preexisting resource allocation. If srun is submitted independent of sbatch, you will need to specify resources to be allocated to your job. 


First, you need to tell SLURM the number of cores you want to run on. You do this with the -n flag. The number of cores you request from the program should always be the same as the number of cores you request from Slurm. Note that different programs have different options to specify multiple cores. For example, tophat -p 8 asks the Tophat aligner for eight cores. So you might runhave a job submission script that has a line to request 8 cores:

Code Block
srun#SBATCH -p short -t 1:00 -n 8 tophat

Later on in the script, you have a tophat alignment command, which also specifies using 8 cores:

Code Block
tophat -p 8 ...

If you accidentally ask for only one core in the job submission (
sbatch -n 1), but try to let your program use multiple cores (tophat -p 8), you will not be able to do so. On O2, CPU usage is restricted to the cores you request, which is performed by the Cgroups plugin.You will not receive an explicit error message, but nevertheless, your job will be confined to the allocated cores. For this reason, you may observe a performance decay when running jobs on O2 instead of Orchestra, because in Orchestra your jobs were using multiple cores that were not allocated to you.