Skip to content

Job Submission

Define and Submit a Batch Script

Copy a job template, set your account and resources within the allocation limits, and submit from a login node:

sbatch gpu-job.sh

Slurm prints Submitted batch job 12345. This confirms acceptance into the queue; use Job Monitoring to check when it starts. Batch jobs continue after you disconnect.

Put #SBATCH directives before the first executable command. Shell variables such as $HOME are not expanded in directives.

The templates write %x-%j.out and %x-%j.err in the submission directory: %x is the job name and %j the job ID. To choose another directory:

sbatch --output="$HOME/%x-%j.out" --error="$HOME/%x-%j.err" gpu-job.sh

Jobs stop at their time limit; save progress if your application supports it. See the sbatch reference.

Job Specifications

Option Argument Meaning
--job-name, -J name Job label
--partition, -p gh200 Resource queue
--account, -A Slurm account Allocation account charged for usage
--nodes, -N count Number of nodes
--ntasks, -n count Total tasks, usually MPI processes
--ntasks-per-node count Tasks per node
--cpus-per-task, -c count Allocated CPUs per task; configure application threads separately
--gres gpu:1 Request one GPU per node
--time, -t HH:MM:SS Maximum job duration
--mem size Host memory per node, such as 4G
--mem-per-cpu size Host memory per allocated CPU; use instead of --mem
--output, -o filename Standard-output path
--error, -e filename Standard-error path
--dependency, -d afterok:JOBID Wait for another job to complete successfully

Memory values without a suffix are in MiB. --cpus-per-task reserves CPUs but does not itself make a serial program parallel. Use the resource layout required by your application.

SLURM Environment Variables

Slurm sets these variables inside a batch job so scripts can use the assigned resources and submission context:

Variable Meaning
$SLURM_JOB_ID Job ID
$SLURM_JOB_NAME Job name
$SLURM_SUBMIT_DIR Directory from which sbatch was called
$SLURM_SUBMIT_HOST Submission host
$SLURM_JOB_NODELIST Allocated node list, possibly in compressed form
$SLURM_JOB_NUM_NODES Number of allocated nodes
$SLURM_CPUS_ON_NODE CPUs available to the job on the current node
$SLURM_CPUS_PER_TASK CPUs per task when explicitly requested
$SLURM_NTASKS Total task count for a task-based request
$SLURM_NTASKS_PER_NODE Tasks per node when explicitly requested