Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
slurm_basics [2018/12/06 14:51] – created xteng | slurm_basics [2024/03/26 13:52] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Main Slurm Commands ====== | ====== Main Slurm Commands ====== | ||
- | **SBatch** | + | **sbatch** |
The sbatch command submits a batch processing job to the slurm queue manager. These scripts typically contain one or more srun commands to queue jobs for processing. | The sbatch command submits a batch processing job to the slurm queue manager. These scripts typically contain one or more srun commands to queue jobs for processing. | ||
- | **SRun** | + | **srun** |
The srun command is used to submit jobs for execution, or to initiate steps of jobs in real time. For the full range of options that can be passed to the srun command, see the UNIX man page for srun (type man srun at the command prompt). | The srun command is used to submit jobs for execution, or to initiate steps of jobs in real time. For the full range of options that can be passed to the srun command, see the UNIX man page for srun (type man srun at the command prompt). | ||
- | **SCancel** | + | **scancel** |
The scancel command will terminate pending and running job steps. You can also use it to send a unix signal to all processes associated with a running job or job step. | The scancel command will terminate pending and running job steps. You can also use it to send a unix signal to all processes associated with a running job or job step. | ||
- | **SQueue** | + | **squeue** |
The squeue command will report the state of running and pending jobs. | The squeue command will report the state of running and pending jobs. | ||
- | **SInfo** | + | **sinfo** |
The sinfo command will report the status of the available partitions and nodes. | The sinfo command will report the status of the available partitions and nodes. | ||
- | **SMap** | + | **smap** |
The smap command is similar to the sinfo command, except it displays all of the information in a pseudo-graphical, | The smap command is similar to the sinfo command, except it displays all of the information in a pseudo-graphical, | ||
+ | **sview** | ||
+ | The sview command is graphical user interface to view and modify Slurm state. | ||
**Example Scripts** | **Example Scripts** | ||
- | | + | * 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:// | ||
+ | < | ||
#!/bin/bash | #!/bin/bash | ||
srun -n 4 my_program | srun -n 4 my_program | ||
+ | </ | ||
+ | * 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. | ||
+ | < | ||
#!/bin/bash | #!/bin/bash | ||
#SBATCH -n 4 | #SBATCH -n 4 | ||
#SBATCH --ntasks-per-node=2 | #SBATCH --ntasks-per-node=2 | ||
#SBATCH --time=00: | #SBATCH --time=00: | ||
- | |||
srun ./ | srun ./ | ||
+ | </ | ||
To submit the script, just run | To submit the script, just run | ||
+ | < | ||
$> sbatch jobscript | $> sbatch jobscript | ||
- | + | </ | |
- | * Script 3 | + | * Script 3 |
Running two jobs per node: | Running two jobs per node: | ||
+ | < | ||
#!/bin/bash | #!/bin/bash | ||
#SBATCH -N 1 | #SBATCH -N 1 | ||
#SBATCH -n 2 | #SBATCH -n 2 | ||
#SBATCH --time=00: | #SBATCH --time=00: | ||
+ | </ | ||
# Use '&' | # Use '&' | ||
+ | < | ||
srun -n 1 ./ | srun -n 1 ./ | ||
srun -n 1 ./ | srun -n 1 ./ | ||
+ | </ | ||
# Use ' | # Use ' | ||
wait | wait | ||
To submit the script, just run | To submit the script, just run | ||
+ | < | ||
$> sbatch jobscript | $> sbatch jobscript | ||
- | + | </ | |
- | * Script 4 | + | * Script 4 |
Naming output and error files: | Naming output and error files: | ||
+ | < | ||
#!/bin/bash | #!/bin/bash | ||
#SBATCH -n 2 | #SBATCH -n 2 | ||
Line 67: | Line 71: | ||
#SBATCH --error=job.%J.err | #SBATCH --error=job.%J.err | ||
#SBATCH --output=job.%J.out | #SBATCH --output=job.%J.out | ||
+ | </ | ||
+ | < | ||
srun ./ | srun ./ | ||
+ | </ | ||
To submit the script, just run | To submit the script, just run | ||
$> sbatch jobscript | $> sbatch jobscript | ||
- | | + | * Script 5 |
+ | < | ||
#!/bin/bash | #!/bin/bash | ||
#SBATCH --nodes=1 #request one node | #SBATCH --nodes=1 #request one node | ||
- | #SBATCH --cpus-per-task=8 #ask for 8 cpus | + | #SBATCH --cpus-per-task=2 #e .g. ask for 2 cpus |
#SBATCH --time=02: | #SBATCH --time=02: | ||
- | #SBATCH --error=job.%J.err # tell it to store the output console text to a file | + | #SBATCH --error=/ |
- | #SBATCH --output=job.%J.out #tell it to store the error messages to a file | + | #SBATCH --output=/ |
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 | ||
+ | </ | ||
To submit the script, just run | To submit the script, just run | ||
+ | < | ||
$> sbatch jobscript | $> sbatch jobscript | ||
- | + | </ | |
- | * Script 6 | + | * Script 6 |
Running a job that needs a GPU | Running a job that needs a GPU | ||
+ | < | ||
#!/bin/bash | #!/bin/bash | ||
Line 115: | Line 122: | ||
Rscript--vanilla myRScript.R #run an R script using R | Rscript--vanilla myRScript.R #run an R script using R | ||
+ | </ | ||
To submit the script, just run | To submit the script, just run | ||
+ | < | ||
$> sbatch jobscript | $> sbatch jobscript | ||
+ | </ | ||
Interactive session example | Interactive session example | ||
To get an interactive session for an hour | To get an interactive session for an hour | ||
+ | < | ||
+ | salloc --time=01: | ||
+ | </ | ||
- | salloc | + | back to [[ace-gpu-1_slurm|ace-gpu-1 slurm]] |