Common SLURM environment variables
Slurm sets these variables inside jobs and job steps. Not all variables will always be set, depending on how the job was launched and the requested resources. An unset variable does not necessarily mean that no resources were allocated.
Variable |
Description |
|---|---|
$SLURM_JOB_ID |
The ID of the job allocation. |
$SLURM_JOBID |
Deprecated. Use |
$SLURM_SUBMIT_DIR |
The directory from which the job was submitted or interactive session started. |
$SLURM_SUBMIT_HOST |
The hostname from which the job was submitted or interactive session started. |
$SLURM_JOB_NODELIST |
Nodes allocated to the job, possibly in a compressed form such as
|
$SLURM_NODELIST |
Deprecated. Use |
$SLURM_CPUS_PER_TASK |
CPUs requested per task. Set when |
$SLURM_CPUS_ON_NODE |
CPUs allocated to the current job step on this node. |
$SLURM_JOB_CPUS_PER_NODE |
CPUs allocated to the job on each node, in |
$SLURM_CPUS_PER_GPU |
CPUs requested per GPU. Set when |
$SLURM_MEM_PER_CPU |
Host RAM per CPU in MB, corresponding to |
$SLURM_MEM_PER_GPU |
Host RAM requested per GPU in MB, set when |
$SLURM_MEM_PER_NODE |
Host RAM per node in MB, set for |
$SLURM_GPUS |
GPUs requested with |
$SLURM_GPUS_ON_NODE |
GPUs available to the current job step on this node. |
$SLURM_JOB_GPUS |
Global GPU IDs allocated to the job. These are device identifiers, not a GPU count or CUDA device indices relative to a job’s device cgroup. |
$SLURM_STEP_GPUS |
Global GPU IDs allocated to the current step, excluding batch and interactive steps. |
$SLURM_NTASKS |
Number of tasks in the job or current job step, corresponding to |
$SLURM_NTASKS_PER_NODE |
Tasks requested per node. Set when |
$SLURM_NTASKS_PER_SOCKET |
Tasks requested per socket. Set when |
$SLURM_NTASKS_PER_CORE |
Tasks requested per core. Set when |
$SLURM_NTASKS_PER_GPU |
Tasks requested per GPU. Set when |
$SLURM_NPROCS |
Deprecated. Use |
$SLURM_JOB_NUM_NODES |
Total number of nodes allocated to the job. |
$SLURM_NNODES |
Deprecated. Use |
$SLURM_TASKS_PER_NODE |
Tasks on each node in |
$SLURM_ARRAY_JOB_ID |
Job array’s master job ID. |
$SLURM_ARRAY_TASK_ID |
Current array task’s index. |
$SLURM_ARRAY_TASK_COUNT |
Total number of tasks in the job array. |
$SLURM_ARRAY_TASK_MAX |
Highest task index in the job array. |
$SLURM_ARRAY_TASK_MIN |
Lowest task index in the job array. |
Array variables apply to array jobs. SLURM_GPUS_ON_NODE, SLURM_JOB_GPUS
and SLURM_STEP_GPUS also apply to --gres=gpu:... requests, subject to
the step restrictions above. Within a GPU job, CUDA_VISIBLE_DEVICES
identifies the CUDA devices visible to the process; its indices can differ from
the global GPU IDs in SLURM_JOB_GPUS or SLURM_STEP_GPUS.
For a full list and the conditions under which variables are set, see the output environment-variable sections of the sbatch manual and the srun manual.