Use the following bsub command
format to submit a batch job or job script:
bsub -n num-procs [bsub-options] script-name
The -n num-procs parameter, which is required for parallel jobs, specifies the number
of cores the job requests.
The script-name argument
is the name of the batch job or script. The script can contain one
or more srun or mpirun commands.
The script will execute once on the first allocated
node, and the srun or mpirun commands within the script will be run on the allocated compute
nodes.
In Example 5-14, a simple script named myscript.sh, which contains two srun commands, is displayed
then submitted.
Example 5-14 Submitting a Job Script
$ cat myscript.sh
#!/bin/sh
srun hostname mpirun -srun hellompi |
$ bsub -I -n4 myscript.sh
Job <29> is submitted to default queue <normal>.
<<Waiting for dispatch ...>>
<<Starting on lsfhost.localdomain>>
n2
n2
n4
n4
Hello world! I'm 0 of 4 on n2
Hello world! I'm 1 of 4 on n2
Hello world! I'm 2 of 4 on n4
Hello world! I'm 3 of 4 on n4 |
Example 5-15 runs the same script but uses the LSF-SLURM External Scheduler
option to specify different resources (here, 4 compute nodes).
Example 5-15 Submitting a Batch Script with the LSF-SLURM External Scheduler
Option
$ bsub -n4 -ext "SLURM[nodes=4]" -I ./myscript.sh
Job <79> is submitted to default queue <normal>.
<<Waiting for dispatch ...>>
<<Starting on lsfhost.localdomain>>
n1
n2
n3
n4
Hello world! I'm 0 of 4 on n1
Hello world! I'm 1 of 4 on n2
Hello world! I'm 2 of 4 on n3
Hello world! I'm 3 of 4 on n4 |
Example 5-16 and Example 5-17 show
how the jobs inside the script can be manipulated within the allocation.
Example 5-16 Submitting a Batch Job Script That Uses a Subset of the Allocation
$ bsub -n4 -ext "SLURM[nodes=4]" -I ./myscript.sh
Job <80> is submitted to default queue <normal>.
<<Waiting for dispatch ...>>
<<Starting on lsfhost.localdomain>>
n1
n2
Hello world! I'm 0 of 2 on n1
Hello world! I'm 1 of 2 on n2 |
Example 5-17 Submitting a Batch job Script That Uses the srun --overcommit
Option
$ bsub -n4 -I ./myscript.sh
Job <81> is submitted to default queue <normal>.
<<Waiting for dispatch ...>>
<<Starting on lsfhost.localdomain>>
n1
n1
n1
n1
n2
n2
n2
n2
Hello world! I'm 0 of 8 on n1
Hello world! I'm 1 of 8 on n1
Hello world! I'm 2 of 8 on n1
Hello world! I'm 3 of 8 on n1
Hello world! I'm 4 of 8 on n2
Hello world! I'm 5 of 8 on n2
Hello world! I'm 6 of 8 on n2
Hello world! I'm 7 of 8 on n2 |
Example 5-18 shows some of the environment variables that
are available in a batch script. The LSB_HOSTS and LSB_MCPU_HOSTS environment variables are defined in Platform LSF Reference. The SLURM_JOBID and SLURM_NPROCS environment variables are defined
in the SLURM Reference Manual.
Example 5-18 Environment Variables Available in a Batch Job Script
$ cat ./envscript.sh
#!/bin/sh
name=`hostname`
echo "hostname = $name"
echo "LSB_HOSTS = '$LSB_HOSTS'"
echo "LSB_MCPU_HOSTS = '$LSB_MCPU_HOSTS'"
echo "SLURM_JOBID = $SLURM_JOBID"
echo "SLURM_NPROCS = $SLURM_NPROCS"
$ bsub -n4 -I ./envscript.sh
Job <82> is submitted to default queue <normal>.
<<Waiting for dispatch ...>>
<<Starting on lsfhost.localdomain>>
hostname = n1
LSB_HOSTS = 'n1 n1 n2 n2'
LSB_MCPU_HOSTS = 'n1 2 n2 2'
SLURM_JOBID = 176
SLURM_NPROCS = 4 |