LSF to Slurm quick reference
Introduction¶
The commands for Slurm are similar to the ones used in LSF. You can find a mapping of the relevant commands below.
Job submission¶
Simple command¶
| LSF | Slurm |
|---|---|
| bsubcommand |
sbatch --wrap=command |
| bsub "command1;command2" |
sbatch --wrap="command1;command2" |
| bsub "command1|command2" |
sbatch --wrap="command1|command2" |
| bsub [LSF options]command |
sbatch [slurm options] --wrap="command" |
Frequently used bsub/sbatch options¶
Parameter |
|
|
|---|---|---|
Job name |
|
|
Job array consisting of N sub-jobs |
|
|
Ouput file (stdout) |
|
|
Error file (stderr) |
|
|
Wall-clock time (default: 4h) |
|
|
Number of cores (default: 1) |
|
|
Number of cores per node |
|
|
Memory per core (default: 1024 MB) |
|
|
Number of GPUs (default: 0) |
|
|
Memory per GPU |
|
|
Local scratch space per core |
|
not available |
Local scratch space per node |
not available |
|
Run job under a specific shareholder group |
|
|
Notify user by email when job starts |
|
|
|Notify user by email when job ends |
|
|
Shell script¶
LSF |
Slurm |
|---|---|
| |
|
Job parameters can be passed as options to
|
Job parameters can be passed as options to
|
Note:
- In LSF, the
jobscript.shmust be passed tobsubvia the "<" operator - In LSF, scratch space is expressed per core, while in Slurm it is per node
- In LSF, the default output file is "
lsf.oJOBID", while in Slurm it is "slurm-JOBID.out"
Interactive job¶
| LSF | Slurm |
|---|---|
| bsub -Is [LSF options] bash |
srun --pty bash |
Parallel job¶
Shared memory (OpenMP, threads)¶
| LSF | Slurm |
|---|---|
| bsub -n 128 -R "span[ptile=128]" |
sbatch -n 1 --cpus-per-task=128 |
Distributed memory (MPI, processes)¶
LSF |
Slurm |
|---|---|
| |
|
The Slurm options
--ntasks-per-core,--cpus-per-task,--nodes, and--ntasks-per-node
are supported.
Please note that for larger parallel MPI jobs that use more than a single node (more than 128 cores), you should add the sbatch option
-C ib
to make sure that they get dispatched to nodes that have the infiniband highspeed interconnect, as this will result a much better performance.
Job array¶
LSF |
Slurm |
|---|---|
|
|
|
|
|
|
Environment variables defined in each job:
|
Environment variables defined in each job:
|
LSF example:
bsub -J "myarray[1-4]" 'echo "Hello, I am task $LSB_JOBINDEX of $LSB_JOBINDEX_END"'
Slurm example:
sbatch --array=1-4 --wrap='echo "Hello, I am task $SLURM_ARRAY_TASK_ID of $SLURM_ARRAY_TASK_COUNT"'
GPU job¶
| LSF | Slurm |
|---|---|
| bsub -R "rusage[ngpus_excl_p=1]" |
sbatch --gpus=1 |
For multi-node jobs you need to use the --gpus-per-node option
instead.
GPU job requiring a specific GPU model¶
| LSF | Slurm |
|---|---|
| bsub -R "rusage[ngpus_excl_p=1]" -R "select[gpu_model0==NVIDIAGeForceGTX1080]" |
sbatch --gpus=gtx_1080:1 |
| bsub -R "rusage[ngpus_excl_p=1]" -R "select[gpu_model0==NVIDIAGeForceRTX3090]" |
sbatch --gpus=rtx_3090:1 |
- For Slurm, currently the specifiers gtx_1080 and rtx_3090 are supported until we add more GPU types.
GPU job requiring a given amount of GPU memory¶
| LSF | Slurm |
|---|---|
| bsub -R "rusage[ngpus_excl_p=1]" -R "select[gpu_mtotal0>=20480]" |
sbatch --gpus=1 --gres=gpumem:20g |
The default unit for gpumem is bytes. You are therefore advised to
specify units, for example 20g or 11000m.
Submit a job using a specific share¶
| LSF | Slurm |
|---|---|
| bsub -Ges_example |
sbatch -Aes_example |
In Slurm, one can define a default share using the command:
"echo account=es_example>> $HOME/.slurm/defaults"
Submit a job on a specific CPU model¶
| LSF | Slurm |
|---|---|
| bsub -R "select[model==EPYC_7H12]" |
sbatch --constraint=EPYC_7H12 |
Job chains¶
LSF |
Slurm |
|---|---|
| |
|
Job dependencies¶
LSF |
Slurm |
|---|---|
| Job #1:
|
Job #1:
|
In Slurm, sbatch --parsable returns the JOBID of the job
Job control¶
Job status¶
| LSF | Slurm |
|---|---|
| bjobs [JOBID] |
squeue [-j JOBID] |
| bjobs -p |
squeue -u USERNAME -t PENDING |
| bjobs -r |
squeue -u USERNAME -t RUNNING |
Resource usage¶
| LSF | Slurm |
|---|---|
| bbjobs [JOBID] |
myjobs -j JOBID |
| | | scontrol show jobid -dd JOBID |
| | | sacct -l -j JOBID for finished jobs |
| | | sstat [--all] JOBID for running jobs |
Use
--format JobID,User,State,AllocCPUS,Elapsed,NNodes,NTasks,TotalCPU,REQMEM,MaxRSS,ExitCode
instead of -l for a customizable, more readable output.
Killing a job¶
| LSF | Slurm |
|---|---|
| bkill [JOBID] |
scancel [JOBID] |
Environment variables¶
| LSF | Slurm |
|---|---|
| $LSB_JOBID |
$SLURM_JOB_ID |
$LSB_SUBCWD |
$SLURM_SUBMIT_DIR |