Requesting Resources
This page explains how to request CPUs, memory, runtime, and GPUs for Slurm jobs.
CPUs, memory, and time
Declare CPUs, memory, and runtime when submitting with sbatch flags. Example requesting 4 CPU cores, 16G memory, and 2 hours on the normal partition:
sbatch -A <account> -p normal --cpus-per-task=4 --mem=16G --time=02:00:00 job.sh
Slurm accepts several time formats: days-hours:minutes:seconds, hours:minutes:seconds, or plain minutes. Examples using the --time flag:
sbatch -A <account> -p normal --time=30 job.sh
sbatch -A <account> -p normal --time=02:00:00 job.sh
sbatch -A <account> -p normal --time=1-00:00:00 job.sh
Be conservative with requests during testing, then scale up once the job behavior is confirmed.
GPU jobs
GPU jobs must request GPUs explicitly so the scheduler can place the job on compatible hardware.
If your code runs on any GPU, request a generic GPU:
sbatch -A <account> -p debug --gres=gpu:1 --wrap='hostname'
Request multiple GPUs:
sbatch -A <account> -p normal --gres=gpu:2 job.sh
If you need a specific GPU model, request it explicitly:
sbatch -A <account> -p normal --gres=gpu:mi210:1 job.sh
sbatch -A <account> -p normal --gres=gpu:rtx2080ti:1 job.sh
sbatch -A <account> -p normal --gres=gpu:gtx980ti:1 job.sh
SBATCH directive
All of the flags shown above (for CPUs, memory, time, and GPUs) can instead be placed inside a job script using #SBATCH directives. For example, the sbatch command:
sbatch -A <account> -p normal --cpus-per-task=4 --mem=16G --time=02:00:00 job.sh
is equivalent to putting the following lines in job.sh:
#!/bin/bash
#SBATCH -A <account>
#SBATCH -p normal
#SBATCH --cpus-per-task=4
#SBATCH --mem=16G
#SBATCH --time=02:00:00
# your commands here
Practical tips
- Test on
debugbefore running large GPU workloads. - Request only the GPUs you actually need; do not ask for all GPUs on a node unless required.
- If your job must run on a specific architecture (e.g., CUDA version), load and verify the correct modules in your script before starting the application.