User Tools

Site Tools


slurm_basics

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

Link to this comparison view

Next revision
Previous revision
Last revision Both sides next revision
slurm_basics [2018/12/06 14:51]
xteng created
slurm_basics [2019/02/12 15:06]
xteng
Line 20: Line 20:
  
 **Example Scripts** **Example Scripts**
-  ​* Script 1+* Script 1
 The following snippet runs a program asking for four (4) tasks. The following snippet runs a program asking for four (4) tasks.
 +http://​osirim.irit.fr/​site/​en/​articles/​sbatch-options 
 +<​code>​
 #!/bin/bash #!/bin/bash
 srun -n 4 my_program srun -n 4 my_program
 +</​code>​
 +* Script 2
  
-  * Script 2 
 This script is the same as Script 1 except it uses slurm directives instead of passing the arguments as part of the srun command. This script is the same as Script 1 except it uses slurm directives instead of passing the arguments as part of the srun command.
 +<​code>​
 #!/bin/bash #!/bin/bash
 #SBATCH -n 4 #SBATCH -n 4
 #SBATCH --ntasks-per-node=2 #SBATCH --ntasks-per-node=2
 #SBATCH --time=00:​30:​00 #SBATCH --time=00:​30:​00
- 
 srun ./​my_program srun ./​my_program
 +</​code>​
 To submit the script, just run To submit the script, just run
 +<​code>​
 $> sbatch jobscript $> sbatch jobscript
- +</​code>​ 
-  * Script 3+* Script 3
 Running two jobs per node: Running two jobs per node:
 +<​code>​
 #!/bin/bash #!/bin/bash
 #SBATCH -N 1 #SBATCH -N 1
 #SBATCH -n 2 #SBATCH -n 2
 #SBATCH --time=00:​30:​00 #SBATCH --time=00:​30:​00
 +</​code>​
 # Use '&'​ to move the first job to the background # Use '&'​ to move the first job to the background
 +<​code>​
 srun -n 1 ./​job1.batch & srun -n 1 ./​job1.batch &
 srun -n 1 ./​job2.batch srun -n 1 ./​job2.batch
 +</​code>​
 # Use '​wait'​ as a barrier to collect both executables when they are done. # Use '​wait'​ as a barrier to collect both executables when they are done.
 wait wait
  
 To submit the script, just run To submit the script, just run
 +<​code>​
 $> sbatch jobscript $> sbatch jobscript
- +</​code>​ 
-  * Script 4+* Script 4
 Naming output and error files: Naming output and error files:
 +<​code>​
 #!/bin/bash #!/bin/bash
 #SBATCH -n 2 #SBATCH -n 2
Line 67: Line 69:
 #SBATCH --error=job.%J.err #SBATCH --error=job.%J.err
 #SBATCH --output=job.%J.out #SBATCH --output=job.%J.out
 +</​code>​ 
 +<​code>​
 srun ./​my_program srun ./​my_program
 +</​code>​
 To submit the script, just run To submit the script, just run
  
 $> sbatch jobscript $> sbatch jobscript
  
-  ​* Script 5+* Script 5 
 +<​code>​
 #!/bin/bash #!/bin/bash
  
 #SBATCH --nodes=1 #request one node #SBATCH --nodes=1 #request one node
  
-#SBATCH --cpus-per-task= #ask for cpus+#SBATCH --cpus-per-task= #e .g. ask for cpus
  
 #SBATCH --time=02:​00:​00 #ask that the job be allowed to run for 2 hours. #SBATCH --time=02:​00:​00 #ask that the job be allowed to run for 2 hours.
  
-#SBATCH --error=job.%J.err # tell it to store the output console text to a file+#SBATCH --error=/​PATH/<​NAME>​.%J.err # tell it to store the output console text to a file
  
-#SBATCH --output=job.%J.out #tell it to store the error messages to a file+#SBATCH --output=/​PATH/<​NAME>​.%J.out #tell it to store the error messages to a file
  
 module load R #load the most recent version of R available module load R #load the most recent version of R available
  
 Rscript --vanilla myRscript.R #run an R script using R Rscript --vanilla myRscript.R #run an R script using R
 +</​code>​
  
 To submit the script, just run To submit the script, just run
 +<​code>​
 $> sbatch jobscript $> sbatch jobscript
- +</​code>​ 
-  * Script 6+* Script 6
 Running a job that needs a GPU Running a job that needs a GPU
 +<​code>​
 #!/bin/bash #!/bin/bash
  
Line 115: Line 120:
  
 Rscript--vanilla myRScript.R #run an R script using R Rscript--vanilla myRScript.R #run an R script using R
 +</​code>​
 To submit the script, just run To submit the script, just run
 +<​code>​
 $> sbatch jobscript $> sbatch jobscript
 +</​code>​
    
  
 Interactive session example Interactive session example
 To get an interactive session for an hour To get an interactive session for an hour
 +<​code>​
 +salloc --time=01:​00:​00 --nodes=1
 +</​code>​
  
-salloc ​--time=01:​00:​00 ​--nodes=1+back to [[ace-gpu-1_slurm|ace-gpu-1 slurm]]
slurm_basics.txt · Last modified: 2019/02/12 15:08 by xteng