Salloc Environment Variables

The following information is largely replicated from SchedMD’s salloc man page, and is the subset that is likely most relevant to most NCCS users.

The salloc command honors the following environment variables, when present (these override any inline directives within your batch script, but will be overridden by those also specified on the salloc command line):

Input Variables

SALLOC_ACCOUNTSame as -A, –account
SALLOC_BELLSame as –bell
SALLOC_IMMEDIATESame as -I, –immediate
SALLOC_JOB_NAMESame as -J, –job-name
SALLOC_QOSSame as -q, –qos
SALLOC_TIMELIMITSame as -t, –time

and sets the following output variables, which are present in the job’s environment during execution (run ‘env | grep SLURM’ within your job, to obtain a full list):

Output Variables

SLURM_JOB_IDNumeric ID of the job allocation
SLURM_JOB_CPUS_PER_NODECount of processors available to the job on this node.
SLURM_CPUS_PER_TASKNumber of cpus requested per task. Only set if the –cpus-per-task option is specified.
SLURM_DISTRIBUTIONSame as -m, –distribution
SLURM_JOB_NODELIST(and SLURM_NODELIST for backwards compatibility): List of nodes allocated to the job.
SLURM_JOB_NUM_NODES(and SLURM_NNODES for backwards compatibility): Total number of nodes in the job’s resource allocation.
SLURM_JOB_PARTITIONName of the partition in which the job is running.
SLURMD_NODENAMEName of the node upon which the current job step executes (value is equal to output of linux ‘hostname -s’ command).
SLURM_NTASKS (and SLURM_NPROCS for backwards compatibility)Same as -n, –ntasks
SLURM_NTASKS_PER_NODESet to the value of –ntasks-per-node, if specified
SLURM_PROCIDThe MPI rank (or relative process ID) of the current process
SLURM_RESTART_COUNTIf the job has been restarted due to system failure or has been explicitly requeued, this will be set to the number of times the job has been restarted.
SLURM_SUBMIT_DIRThe directory from which salloc was invoked.
SLURM_SUBMIT_HOSTThe host from which salloc was invoked.
SLURM_TASKS_PER_NODENumber of tasks to be initiated on each node. Values are comma separated and in the same order as SLURM_NODELIST. If two or more consecutive nodes are to have the same task count, that count is followed by “(x#)” where “#” is the repetition count. For example, “SLURM_TASKS_PER_NODE=2(x3),1” indicates that the first three nodes will each execute three tasks and the fourth node will execute one task.

For more information on salloc, please refer to the man pages. Use the following command, after you’ve logged onto Discover:

man salloc

or

salloc -help


Category:

Tags: