Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hpc-compendium
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ZIH
hpcsupport
hpc-compendium
Commits
c7264650
Commit
c7264650
authored
1 year ago
by
Martin Schroschk
Browse files
Options
Downloads
Patches
Plain Diff
WIP Add page on Slurm environment variables
parent
aafafaf9
Branches
slurm-env-vars
No related tags found
1 merge request
!954
Draft: WIP Add page on Slurm environment variables
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc.zih.tu-dresden.de/docs/jobs_and_resources/slurm_env_vars.md
+69
-0
69 additions, 0 deletions
...h.tu-dresden.de/docs/jobs_and_resources/slurm_env_vars.md
doc.zih.tu-dresden.de/mkdocs.yml
+1
-0
1 addition, 0 deletions
doc.zih.tu-dresden.de/mkdocs.yml
with
70 additions
and
0 deletions
doc.zih.tu-dresden.de/docs/jobs_and_resources/slurm_env_vars.md
0 → 100644
+
69
−
0
View file @
c7264650
Slurm Environment Variables
*
Following is restricted to
`sbatch`
command
*
Differentiation between input and output variables
The Slurm controller will set variables in the environment of the batch script
## Input Environment Variables
Upon startup,
`sbatch`
will read and handle the options set in the so-called
*
input environment
variables
*
. With few exceptions, all input variables will be set the same way as the corresponding
commandline options and
`#SBATCH`
directives. The following table provides some input environment
variables and the equivalent option to
`sbatch`
.
For a comprehensive documentation, please visit Slurm's
[
page on input variables for sbatch
](
https://slurm.schedmd.com/sbatch.html#SECTION_INPUT-ENVIRONMENT-VARIABLES
)
. Here, you will find the entire list of input variables for the latest Slurm version. ZIH systems
might operate on a older Slurm version.
| Environment Variable | Equivalent Option |
|:------------------------------|:-------------------|
|
`SBATCH_ACCOUNT`
|
`-A, --account`
|
|
`SBATCH_CONSTRAINT`
|
`-C, --constraint`
|
|
`SBATCH_ERROR`
|
`-e, --error`
|
|
`SBATCH_OUPUT`
|
`-o, --output`
|
|
`SBATCH_JOB_NAME`
|
`-J, --job-name`
|
|
`SBATCH_HINT`
or
`SLURM_HINT`
|
`--hint`
|
|
`SBATCH_MEM_BIN`
|
`--mem-bind`
|
!!! note "Priority: Commandline option > env. variable > option in jobfile"
Environment variables will override any options set in a batch script, and command line options
will override any environment variables.
## Output Environment Variables
The Slurm controller will set a number of
*output environment variables*
in the environment of the
batch script. This allows to obtain values of Slurm parameters within the environment of the job
script, e.g.,
`SLURM_JOB_ID`
,
`SLURM_NTASKS`
,
`SLURM_CPUS_PER_TASK`
,
`SLURM_MEM_PER_NODE`
,
`SLURM_JOB_NODELIST`
,
`SLURM_JOB_NUM_NODES`
and many more, which is quite useful for automation and
generalisation of job scripts.
!!! example ""
The following skeleton of a job script for an OpenMP-parallel application depicts the
generalization w.r.t. setting the number of threads basing on the environment variable
`SLURM_CPUS_PER_TASKS`. By this, you can only have to adjust the number of cpus per tasks within
the SBATCH directive and the OpenMP environment variable will set to the right value
automatically.
```console
#!/bin/bash
#SBATCH --cpus-per-task=4
[...]
if [ ! -z "${SLURM_CPUS_PER_TASK}" ] ; then
export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}
else
export OMP_NUM_THREADS=1
fi
```
## Exporting Environment Variables to Slurm Jobs
WIP:
Using the
`--export`
option, you can export variables to the Slurm job at submit time.
<!--https://slurm.schedmd.com/sbatch.html#OPT_export_4-->
This diff is collapsed.
Click to expand it.
doc.zih.tu-dresden.de/mkdocs.yml
+
1
−
0
View file @
c7264650
...
...
@@ -114,6 +114,7 @@ nav:
-
Batch System Slurm
:
jobs_and_resources/slurm.md
-
Job Examples
:
jobs_and_resources/slurm_examples.md
-
Slurm Resource Limits
:
jobs_and_resources/slurm_limits.md
-
Slurm Environment Variables
:
jobs_and_resources/slurm_env_vars.md
-
Slurm Job File Generator
:
jobs_and_resources/slurm_generator.md
-
Checkpoint/Restart
:
jobs_and_resources/checkpoint_restart.md
-
Binding and Distribution of Tasks
:
jobs_and_resources/binding_and_distribution_of_tasks.md
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment