A batch job is simple Linux Bash Shell script that contain a set of commands that are executed by Slurm. The top of the script must contain instructions for the Slurm Batch scheduler, in the form of comments starting with SBATCH, that will informs Slurm the type and amount of resources that are being requested. For example consider the following script:
#!/bin/bash
#
#SBATCH --job-name=someapp
#SBATCH --output=somejob-%j.out
#
#SBATCH --partition=cmp
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=6
#SBATCH --mem-per-cpu=4G
#SBATCH --time=02:00:00
#
#SBATCH --mail-user=user_account@scu.edu
#SBATCH --mail-type=END
# Load the software to run the program
module load Python
# Run the Program
python ./somepythonprog -o outdir -a param1 -b param2 ...
The script executes a python program with the parameters provided on the command line.
The SBATCH comment lines in the script tell Slurm to reserve 6 cpu cores and 24GB of memory ( 4G per cpu x 6 cpu = 24G) on a single compute node from the cmp partition. The resources will be reserved for at most 2 hours of time.
The SBATCH comment lines also tell Slurm the name of the job and where to direct the output of the job. In addition, the mail-user and mail-type parameters specify that Slurm should email the user at the provided address when the job completes or terminates for some unforeseen reason (e.g., if it has run out of time).
Assuming the script above is stored in a file called myscript.sh, you can schedule the job by executing:
sbatch myscript.sh
If what you desire is GPU processing, then you would use the gpu partition and add a –gres option to the sbatch script as follows.
#!/bin/bash
#
#SBATCH --job-name=someapp
#SBATCH --output=somejob-%j.out
#
#SBATCH --partition=gpu
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=6
#SBATCH --gres=gpu:1
#SBATCH --mem-per-cpu=4G
#SBATCH --time=02:00:00
#
#SBATCH --mail-user=user_account@scu.edu
#SBATCH --mail-type=END
...
More information on the sbatch command and the various parameters can be found at https://slurm.schedmd.com/sbatch.html.