Helix/Slurm: Difference between revisions
S Richling (talk | contribs) |
H Schumacher (talk | contribs) m (fixed formatting) |
||
| (113 intermediate revisions by 3 users not shown) | |||
| Line 12: | Line 12: | ||
| [https://slurm.schedmd.com/sbatch.html sbatch] || Submits a job and queues it in an input queue |
| [https://slurm.schedmd.com/sbatch.html sbatch] || Submits a job and queues it in an input queue |
||
|- |
|- |
||
| [https://slurm.schedmd.com/salloc.html |
| [https://slurm.schedmd.com/salloc.html salloc] || Request resources for an interactive job |
||
|- |
|- |
||
| [https://slurm.schedmd.com/squeue.html squeue] || Displays information about active, eligible, blocked, and/or recently completed jobs |
| [https://slurm.schedmd.com/squeue.html squeue] || Displays information about active, eligible, blocked, and/or recently completed jobs |
||
| Line 28: | Line 28: | ||
Batch jobs are submitted with the command: |
Batch jobs are submitted with the command: |
||
< |
<syntaxhighlight lang="bash">sbatch <job-script> </syntaxhighlight> |
||
A job script contains options for Slurm in lines beginning with #SBATCH as well as your commands which you want to execute on the compute nodes. For example: |
A job script contains options for Slurm in lines beginning with <code>#SBATCH</code> as well as your commands which you want to execute on the compute nodes. For example: |
||
<syntaxhighlight lang="slurm">#!/bin/bash |
|||
<source lang='bash'> |
|||
#SBATCH --partition=cpu-single |
|||
#!/bin/bash |
|||
#SBATCH --partition=single |
|||
#SBATCH --ntasks=1 |
#SBATCH --ntasks=1 |
||
#SBATCH --time=00:20:00 |
#SBATCH --time=00:20:00 |
||
| Line 40: | Line 39: | ||
#SBATCH --export=NONE |
#SBATCH --export=NONE |
||
echo 'Hello world' |
echo 'Hello world' |
||
</syntaxhighlight> |
|||
</source> |
|||
This jobs requests one core (--ntasks=1) and 1 GB memory (--mem=1gb) for 20 minutes (--time=00:20:00) on nodes provided by the partition 'single'. |
This jobs requests one core (--ntasks=1) and 1 GB memory (--mem=1gb) for 20 minutes (--time=00:20:00) on nodes provided by the partition ''cpu-single''. |
||
For the sake of a better reproducibility of jobs it is recommended to use the option --export=NONE to prevent the propagation of environment variables from the submit session into the job environment and to load required software modules in the job script. |
For the sake of a better reproducibility of jobs it is recommended to use the option --export=NONE to prevent the propagation of environment variables from the submit session into the job environment and to load required software modules in the job script. |
||
| Line 48: | Line 47: | ||
== Partitions == |
== Partitions == |
||
On bwForCluster Helix it is necessary to request a partition with |
On bwForCluster Helix it is necessary to request a partition with <code>--partition=<partition_name></code> on job submission. Within a partition, job allocations are routed automatically to the most suitable compute node(s) for the requested resources (e.g. amount of nodes and cores, memory, number of GPUs). The ''devel'' partition is the default partition, if no partition is requested. |
||
The partitions devel and single are operated in shared mode, i.e. jobs from different users can run on the same node. Jobs can get exclusive access to compute nodes in these partitions with the "--exclusive" option. The partitions cpu-multi and gpu-multi are operated in exclusive mode. Jobs in these partitions automatically get exclusive access to the requested compute nodes. |
|||
The partitions ''devel'', ''cpu-single'' and ''gpu-single'' are operated in shared mode, i.e. jobs from different users can run on the same node. Jobs can get exclusive access to compute nodes in these partitions with the <code>--exclusive</code> option. The partitions ''cpu-multi'' and ''gpu-multi'' are operated in exclusive mode. Jobs in these partitions automatically get exclusive access to the requested compute nodes. |
|||
GPUs are requested with the option "--gres=gpu:<number-of-gpus>". |
|||
{| class="wikitable" |
{| class="wikitable" |
||
| Line 68: | Line 65: | ||
| nodes=2, time=00:30:00 |
| nodes=2, time=00:30:00 |
||
|- |
|- |
||
| single |
| cpu-single |
||
| shared |
| shared |
||
| cpu, fat |
| cpu, fat |
||
| ntasks=1, time=00:30:00, mem-per-cpu=2gb |
|||
| nodes=1, time=120:00:00 |
|||
|- |
|||
| gpu-single |
|||
| shared |
|||
| gpu4, gpu8 |
|||
| ntasks=1, time=00:30:00, mem-per-cpu=2gb |
| ntasks=1, time=00:30:00, mem-per-cpu=2gb |
||
| nodes=1, time=120:00:00 |
| nodes=1, time=120:00:00 |
||
| Line 87: | Line 90: | ||
|} |
|} |
||
== |
== GPU requests == |
||
For the partitions ''gpu-single'' and ''gpu-multi'' is it required to request GPU resources. |
|||
It is possible to request explicitly the CPU manufacturer of compute nodes with the option "--constraint=<constraint_name>". |
|||
* The number of GPUs per node is requested with the option <code>--gres=gpu:<number-of-gpus></code>. |
|||
* It is recommended to request a suitable GPU type for your application with the option <code>--gres=gpu:<gpu-type>:<number-of-gpus></code>. |
|||
{| class="wikitable" |
|||
** For <gpu-type> put the 'GPU Type' listed in the [https://wiki.bwhpc.de/e/Helix/Hardware#Compute_Nodes Compute Nodes table]. |
|||
|- |
|||
*** Example for a request of two A40 GPUs: <code>--gres=gpu:A40:2</code> |
|||
! style="width:20%"| Constraint |
|||
*** Example for a request of one A100 GPU: <code>--gres=gpu:A100:1</code> |
|||
! style="width:80%"| Meaning |
|||
** If you are unsure on which GPU type your code runs faster, please run a test case and compare the run times. In general the following applies: |
|||
|- |
|||
*** A40 GPUs are optimized for single precision computations. |
|||
| amd |
|||
*** A100 and H200 GPUs offer better performance for double precision computations or if the code makes use of tensor cores. |
|||
| request AMD nodes (default) |
|||
** To only get A100 or H200 for double precision computations, a matching constraint can be added to the job parameters by using <code>--constraint=fp64</code>. This way, only GPU types with FP64 capability (double precision) are allowed. |
|||
|- |
|||
* GPUs that are suitable for a specific GPU memory requirement can be requested with option <code>--gres=gpu:<number-of-gpus>,gpumem_per_gpu:<required-gpumem>GB</code>. |
|||
| intel |
|||
*: Hint: This only restricts the selection of possible GPU types. For the job the total GPU memory per GPU is available as listed in the line 'GPU memory per GPU' of the [https://wiki.bwhpc.de/e/Helix/Hardware#Compute_Nodes Compute Nodes table]. |
|||
| request Intel nodes (when available) |
|||
|} |
|||
== Examples == |
== Examples == |
||
Here you can find some |
Here you can find some example scripts for batch jobs. |
||
=== Serial Programs === |
=== Serial Programs === |
||
< |
<syntaxhighlight lang="slurm"> |
||
#!/bin/bash |
|||
#SBATCH --partition=single |
|||
#SBATCH --partition=cpu-single |
|||
#SBATCH --ntasks=1 |
#SBATCH --ntasks=1 |
||
#SBATCH --time= |
#SBATCH --time=20:00:00 |
||
#SBATCH --mem=4gb |
#SBATCH --mem=4gb |
||
./my_serial_program |
|||
</source> |
|||
</syntaxhighlight> |
|||
'''Notes:''' |
'''Notes:''' |
||
* Jobs with "--mem" |
* Jobs with "--mem" up to 236gb can run on all node types associated with the cpu-single partition. |
||
=== Multi-threaded Programs === |
=== Multi-threaded Programs === |
||
< |
<syntaxhighlight lang="slurm"> |
||
#!/bin/bash |
|||
#SBATCH --partition=single |
|||
#SBATCH --partition=cpu-single |
|||
#SBATCH --nodes=1 |
#SBATCH --nodes=1 |
||
#SBATCH --ntasks-per-node= |
#SBATCH --ntasks-per-node=1 |
||
#SBATCH --cpus-per-task=16 |
|||
#SBATCH --time=01:30:00 |
#SBATCH --time=01:30:00 |
||
#SBATCH --mem=50gb |
#SBATCH --mem=50gb |
||
export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK} |
|||
</source> |
|||
./my_multithreaded_program |
|||
</syntaxhighlight> |
|||
'''Notes:''' |
'''Notes:''' |
||
* Jobs with "--ntasks-per-node" up to 64 and "--mem" |
* Jobs with "--ntasks-per-node" up to 64 and "--mem" up to 236gb can run on all node types associated with the cpu-single partition. |
||
* With <code>export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}</code> you can set the number of threads according to the number of resources requested. |
|||
=== MPI Programs === |
=== MPI Programs === |
||
< |
<syntaxhighlight lang="slurm"> |
||
#!/bin/bash |
|||
#SBATCH --partition=cpu-multi |
#SBATCH --partition=cpu-multi |
||
#SBATCH --nodes=2 |
#SBATCH --nodes=2 |
||
#SBATCH --ntasks-per-node=64 |
#SBATCH --ntasks-per-node=64 |
||
#SBATCH --time=12:00:00 |
#SBATCH --time=12:00:00 |
||
module load compiler/gnu |
|||
#SBATCH --mem=50gb |
|||
module load mpi/openmpi |
|||
</source> |
|||
srun ./my_mpi_program |
|||
</syntaxhighlight> |
|||
'''Notes:''' |
'''Notes:''' |
||
* "--mem" requests the memory per node. |
* "--mem" requests the memory per node. The maximum is 236gb. |
||
* The Compiler and MPI modules used for the compilation must be loaded before the start of the program. |
|||
* It is recommended to start MPI programs with 'srun'. |
|||
=== GPU Programs === |
=== GPU Programs === |
||
< |
<syntaxhighlight lang="slurm"> |
||
#!/bin/bash |
|||
#SBATCH --partition=single |
|||
#SBATCH -- |
#SBATCH --partition=gpu-single |
||
#SBATCH -- |
#SBATCH --nodes=1 |
||
#SBATCH -- |
#SBATCH --ntasks=1 |
||
#SBATCH --cpus-per-task=8 |
|||
#SBATCH --gres=gpu:A40:1 |
|||
#SBATCH --time=12:00:00 |
#SBATCH --time=12:00:00 |
||
#SBATCH --mem= |
#SBATCH --mem=16gb |
||
</source> |
|||
module load devel/cuda |
|||
export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK} |
|||
./my_cuda_program |
|||
</syntaxhighlight> |
|||
'''Notes:''' |
'''Notes:''' |
||
* The CUDA module used for compilation must be loaded before the start of the program. |
|||
* The number of GPUs per node is requested with the option "--gres=gpu:<number-of-gpus>" |
|||
* It is possible to request a certain GPU type with the option "--gres=gpu:<gpu-type>:<number-of-gpus>". For <gpu-type> put the 'GPU Type' listed in the last line of the [https://wiki.bwhpc.de/e/Helix/Hardware GPU Nodes Hardware table]. |
|||
=== More Examples === |
|||
Further batch script examples are available on bwForCluster Helix in the directory: <code>/opt/bwhpc/common/system/slurm-examples</code> |
|||
= Interactive Jobs = |
= Interactive Jobs = |
||
'''Hint:''' For convenient access to specific GUI applications (JupyterLab, RStudio, ...) on the cluster, we provide a web-based platform: </br> |
|||
Interactive jobs must NOT run on the logins nodes, however resources for interactive jobs can be requested using srun. The following example requests an interactive session on 1 core for 2 hours: |
|||
→ '''[[Helix/bwVisu | bwVisu]]''' |
|||
Interactive jobs must NOT run on the login nodes, however resources for interactive jobs can be requested using srun. The following example requests an interactive session on 1 core for 2 hours: |
|||
< |
<syntaxhighlight lang="bash">salloc --partition=cpu-single --ntasks=1 --time=2:00:00 </syntaxhighlight> |
||
After execution of this command wait until the queueing system has granted you the requested resources. Once granted you will be automatically logged on the allocated compute node. |
After execution of this command wait until the queueing system has granted you the requested resources. Once granted you will be automatically logged on the allocated compute node. |
||
| Line 170: | Line 196: | ||
If you use applications or tools which provide a GUI, enable X-forwarding for your interactive session with: |
If you use applications or tools which provide a GUI, enable X-forwarding for your interactive session with: |
||
< |
<syntaxhighlight lang="bash">salloc --partition=cpu-single --ntasks=1 --time=2:00:00 --x11 </syntaxhighlight> |
||
Once the walltime limit has been reached you will be automatically logged out from the compute node. |
Once the walltime limit has been reached you will be automatically logged out from the compute node. |
||
'''Delay the start of a job''' by using [https://slurm.schedmd.com/sbatch.html#OPT_begin -b] (or [https://slurm.schedmd.com/sbatch.html#OPT_begin --begin]) option in order to defer the allocation of the job until the specified time. Examples: |
|||
<syntaxhighlight lang="bash">salloc --begin=20:00 ... # job can start after 8 p.m. |
|||
salloc --begin=now+1hour ... # job can start 1 hour after submission |
|||
salloc --begin=teatime ... # job can start at teatime (4 p.m.) |
|||
salloc --begin=2023-12-24T20:00:00 ... # job can start after specified date/time |
|||
</syntaxhighlight> |
|||
= Job Monitoring = |
= Job Monitoring = |
||
Jobs can be monitored via the job monitoring portal or via the commandline. |
|||
== Information about submitted jobs == |
|||
== Job Monitoring Portal == |
|||
For detailed information about your jobs and their efficiency (requested resources vs. used resources) visit the job monitoring portal: |
|||
→ https://helix-monitoring.bwservices.uni-heidelberg.de |
|||
== Commandline Commands == |
|||
Depending on the job state and type you can use different commands to get information on the job. |
|||
=== Information about Submitted Jobs === |
|||
For an overview of your submitted jobs use the command: |
For an overview of your submitted jobs use the command: |
||
< |
<syntaxhighlight lang="bash">squeue |
||
# Show the estimated start time, additionally: |
|||
squeue --start</syntaxhighlight> |
|||
To get detailed information about a specific job use the command: |
|||
<syntaxhighlight lang="bash">scontrol show job <jobid></syntaxhighlight> |
|||
To get detailed information about a specific jobs use the command: |
|||
'''Notes:'''<br> |
|||
<source lang=bash>$ scontrol show job <jobid></source> |
|||
A job start may be delayed for various reasons: |
|||
* <code>QOSMaxCpuPerUserLimit</code> - There is a limit to how many CPU cores a user can use at the same time. The job exceeds this limit. |
|||
* <code>QOSMaxGRESPerUser</code> - There is a limit to how many GPUs a user can use at the same time. The job exceeds this limit. |
|||
* <code>QOSMinGRES</code> - The job was submitted to a gpu partition without requesting a GPU. |
|||
* <code>Priority</code> - There are currently other jobs with a higher priority but afterwards your job will run. |
|||
* <code>launch failed requeued held</code> - The job has failed to start. You may be able to resume it using scontrol. Alternatively you can cancel it and submit it again. |
|||
For further reasons please refer to: https://slurm.schedmd.com/job_reason_codes.html |
|||
== |
=== Information about resource usage of running jobs === |
||
You can monitor the resource usage of running jobs with the sstat command. For example: |
You can monitor the resource usage of running jobs with the sstat command. For example: |
||
<pre> |
<pre> |
||
sstat --format=JobId,AveCPU,AveRSS,MaxRSS -j <jobid> |
|||
</pre> |
</pre> |
||
| Line 198: | Line 252: | ||
'sstat -e' command shows a list of fields that can be specified with the '--format' option. |
'sstat -e' command shows a list of fields that can be specified with the '--format' option. |
||
== Interactive access to running jobs == |
=== Interactive access to running jobs === |
||
It is also possible to attach an interactive shell to a running job with command: |
It is also possible to attach an interactive shell to a running job with command: |
||
< |
<syntaxhighlight lang="bash">srun --jobid=<jobid> --overlap --pty /bin/bash</syntaxhighlight> |
||
Commands like 'top' show you the most busy processes on the node. To exit 'top' type 'q'. |
Commands like 'top' show you the most busy processes on the node. To exit 'top' type 'q'. |
||
| Line 208: | Line 262: | ||
To monitor your GPU processes use the command 'nvidia-smi'. |
To monitor your GPU processes use the command 'nvidia-smi'. |
||
= Job Feedback = |
=== Job Feedback === |
||
You |
You get feedback on resource usage and job efficiency for completed jobs with the command: |
||
<syntaxhighlight lang="bash"> |
|||
seff <jobid> |
|||
</syntaxhighlight> |
|||
Example Output: |
Example Output: |
||
< |
<syntaxhighlight lang="bash"> |
||
============================= JOB FEEDBACK ============================= |
============================= JOB FEEDBACK ============================= |
||
Job ID: 12345678 |
Job ID: 12345678 |
||
| Line 226: | Line 284: | ||
Memory Utilized: 432.74 GB (estimated maximum) |
Memory Utilized: 432.74 GB (estimated maximum) |
||
Memory Efficiency: 85.96% of 503.42 GB (251.71 GB/node) |
Memory Efficiency: 85.96% of 503.42 GB (251.71 GB/node) |
||
</syntaxhighlight> |
|||
</source> |
|||
Explanation: |
Explanation: |
||
| Line 234: | Line 292: | ||
* CPU Efficiency: 'CPU Utilized' with respect to core-walltime (= 'Nodes' x 'Cores per node' x 'Job Wall-clock time') in percent. |
* CPU Efficiency: 'CPU Utilized' with respect to core-walltime (= 'Nodes' x 'Cores per node' x 'Job Wall-clock time') in percent. |
||
* Job Wall-clock time: runtime of the job. |
* Job Wall-clock time: runtime of the job. |
||
* Memory Utilized: Sum of memory used. |
* Memory Utilized: Sum of memory used. For multi node MPI jobs the sum is only correct when srun is used instead of mpirun. |
||
* Memory Efficiency: 'Memory Utilized' with respect to total allocated memory for the job. |
* Memory Efficiency: 'Memory Utilized' with respect to total allocated memory for the job. |
||
= Accounting = |
= Accounting = |
||
Jobs are billed for |
Jobs are billed for allocated CPU cores, memory and GPUs. |
||
To see the accounting data of a specific job: |
To see the accounting data of a specific job: |
||
< |
<syntaxhighlight lang="bash">sacct -j <jobid> --format=user,jobid,account,nnodes,ncpus,time,elapsed,AllocTRES%50</syntaxhighlight> |
||
To |
To retrieve the job history for a specific user for a certain time frame: |
||
< |
<syntaxhighlight lang="bash">sacct -u <user> -S 2022-08-20 -E 2022-08-30 --format=user,jobid,account,nnodes,ncpus,time,elapsed,AllocTRES%50</syntaxhighlight> |
||
= Overview about free resources = |
= Overview about free resources = |
||
| Line 253: | Line 311: | ||
On the login nodes the following command shows what resources are available for immediate use: |
On the login nodes the following command shows what resources are available for immediate use: |
||
< |
<syntaxhighlight lang="bash">sinfo_t_idle</syntaxhighlight> |
||
Latest revision as of 17:47, 20 July 2026
General information about Slurm
The bwForCluster Helix uses Slurm as batch system.
- Slurm documentation: https://slurm.schedmd.com/documentation.html
- Slurm cheat sheet: https://slurm.schedmd.com/pdfs/summary.pdf
- Slurm tutorials: https://slurm.schedmd.com/tutorials.html
Slurm Command Overview
| Slurm commands | Brief explanation |
|---|---|
| sbatch | Submits a job and queues it in an input queue |
| salloc | Request resources for an interactive job |
| squeue | Displays information about active, eligible, blocked, and/or recently completed jobs |
| scontrol | Displays detailed job state information |
| sstat | Displays status information about a running job |
| scancel | Cancels a job |
Job Submission
Batch jobs are submitted with the command:
sbatch <job-script>
A job script contains options for Slurm in lines beginning with #SBATCH as well as your commands which you want to execute on the compute nodes. For example:
#!/bin/bash
#SBATCH --partition=cpu-single
#SBATCH --ntasks=1
#SBATCH --time=00:20:00
#SBATCH --mem=1gb
#SBATCH --export=NONE
echo 'Hello world'
This jobs requests one core (--ntasks=1) and 1 GB memory (--mem=1gb) for 20 minutes (--time=00:20:00) on nodes provided by the partition cpu-single.
For the sake of a better reproducibility of jobs it is recommended to use the option --export=NONE to prevent the propagation of environment variables from the submit session into the job environment and to load required software modules in the job script.
Partitions
On bwForCluster Helix it is necessary to request a partition with --partition=<partition_name> on job submission. Within a partition, job allocations are routed automatically to the most suitable compute node(s) for the requested resources (e.g. amount of nodes and cores, memory, number of GPUs). The devel partition is the default partition, if no partition is requested.
The partitions devel, cpu-single and gpu-single are operated in shared mode, i.e. jobs from different users can run on the same node. Jobs can get exclusive access to compute nodes in these partitions with the --exclusive option. The partitions cpu-multi and gpu-multi are operated in exclusive mode. Jobs in these partitions automatically get exclusive access to the requested compute nodes.
| Partition | Node Access Policy | Node Types | Default | Limits |
|---|---|---|---|---|
| devel | shared | cpu, gpu4 | ntasks=1, time=00:10:00, mem-per-cpu=2gb | nodes=2, time=00:30:00 |
| cpu-single | shared | cpu, fat | ntasks=1, time=00:30:00, mem-per-cpu=2gb | nodes=1, time=120:00:00 |
| gpu-single | shared | gpu4, gpu8 | ntasks=1, time=00:30:00, mem-per-cpu=2gb | nodes=1, time=120:00:00 |
| cpu-multi | job exclusive | cpu | nodes=2, time=00:30:00 | nodes=32, time=48:00:00 |
| gpu-multi | job exclusive | gpu4 | nodes=2, time=00:30:00 | nodes=8, time=48:00:00 |
GPU requests
For the partitions gpu-single and gpu-multi is it required to request GPU resources.
- The number of GPUs per node is requested with the option
--gres=gpu:<number-of-gpus>. - It is recommended to request a suitable GPU type for your application with the option
--gres=gpu:<gpu-type>:<number-of-gpus>.- For <gpu-type> put the 'GPU Type' listed in the Compute Nodes table.
- Example for a request of two A40 GPUs:
--gres=gpu:A40:2 - Example for a request of one A100 GPU:
--gres=gpu:A100:1
- Example for a request of two A40 GPUs:
- If you are unsure on which GPU type your code runs faster, please run a test case and compare the run times. In general the following applies:
- A40 GPUs are optimized for single precision computations.
- A100 and H200 GPUs offer better performance for double precision computations or if the code makes use of tensor cores.
- To only get A100 or H200 for double precision computations, a matching constraint can be added to the job parameters by using
--constraint=fp64. This way, only GPU types with FP64 capability (double precision) are allowed.
- For <gpu-type> put the 'GPU Type' listed in the Compute Nodes table.
- GPUs that are suitable for a specific GPU memory requirement can be requested with option
--gres=gpu:<number-of-gpus>,gpumem_per_gpu:<required-gpumem>GB.- Hint: This only restricts the selection of possible GPU types. For the job the total GPU memory per GPU is available as listed in the line 'GPU memory per GPU' of the Compute Nodes table.
Examples
Here you can find some example scripts for batch jobs.
Serial Programs
#!/bin/bash
#SBATCH --partition=cpu-single
#SBATCH --ntasks=1
#SBATCH --time=20:00:00
#SBATCH --mem=4gb
./my_serial_program
Notes:
- Jobs with "--mem" up to 236gb can run on all node types associated with the cpu-single partition.
Multi-threaded Programs
#!/bin/bash
#SBATCH --partition=cpu-single
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=16
#SBATCH --time=01:30:00
#SBATCH --mem=50gb
export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}
./my_multithreaded_program
Notes:
- Jobs with "--ntasks-per-node" up to 64 and "--mem" up to 236gb can run on all node types associated with the cpu-single partition.
- With
export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}you can set the number of threads according to the number of resources requested.
MPI Programs
#!/bin/bash
#SBATCH --partition=cpu-multi
#SBATCH --nodes=2
#SBATCH --ntasks-per-node=64
#SBATCH --time=12:00:00
module load compiler/gnu
module load mpi/openmpi
srun ./my_mpi_program
Notes:
- "--mem" requests the memory per node. The maximum is 236gb.
- The Compiler and MPI modules used for the compilation must be loaded before the start of the program.
- It is recommended to start MPI programs with 'srun'.
GPU Programs
#!/bin/bash
#SBATCH --partition=gpu-single
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=8
#SBATCH --gres=gpu:A40:1
#SBATCH --time=12:00:00
#SBATCH --mem=16gb
module load devel/cuda
export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}
./my_cuda_program
Notes:
- The CUDA module used for compilation must be loaded before the start of the program.
More Examples
Further batch script examples are available on bwForCluster Helix in the directory: /opt/bwhpc/common/system/slurm-examples
Interactive Jobs
Hint: For convenient access to specific GUI applications (JupyterLab, RStudio, ...) on the cluster, we provide a web-based platform:
→ bwVisu
Interactive jobs must NOT run on the login nodes, however resources for interactive jobs can be requested using srun. The following example requests an interactive session on 1 core for 2 hours:
salloc --partition=cpu-single --ntasks=1 --time=2:00:00
After execution of this command wait until the queueing system has granted you the requested resources. Once granted you will be automatically logged on the allocated compute node.
If you use applications or tools which provide a GUI, enable X-forwarding for your interactive session with:
salloc --partition=cpu-single --ntasks=1 --time=2:00:00 --x11
Once the walltime limit has been reached you will be automatically logged out from the compute node.
Delay the start of a job by using -b (or --begin) option in order to defer the allocation of the job until the specified time. Examples:
salloc --begin=20:00 ... # job can start after 8 p.m.
salloc --begin=now+1hour ... # job can start 1 hour after submission
salloc --begin=teatime ... # job can start at teatime (4 p.m.)
salloc --begin=2023-12-24T20:00:00 ... # job can start after specified date/time
Job Monitoring
Jobs can be monitored via the job monitoring portal or via the commandline.
Job Monitoring Portal
For detailed information about your jobs and their efficiency (requested resources vs. used resources) visit the job monitoring portal:
→ https://helix-monitoring.bwservices.uni-heidelberg.de
Commandline Commands
Depending on the job state and type you can use different commands to get information on the job.
Information about Submitted Jobs
For an overview of your submitted jobs use the command:
squeue
# Show the estimated start time, additionally:
squeue --start
To get detailed information about a specific job use the command:
scontrol show job <jobid>
Notes:
A job start may be delayed for various reasons:
QOSMaxCpuPerUserLimit- There is a limit to how many CPU cores a user can use at the same time. The job exceeds this limit.QOSMaxGRESPerUser- There is a limit to how many GPUs a user can use at the same time. The job exceeds this limit.QOSMinGRES- The job was submitted to a gpu partition without requesting a GPU.Priority- There are currently other jobs with a higher priority but afterwards your job will run.launch failed requeued held- The job has failed to start. You may be able to resume it using scontrol. Alternatively you can cancel it and submit it again.
For further reasons please refer to: https://slurm.schedmd.com/job_reason_codes.html
Information about resource usage of running jobs
You can monitor the resource usage of running jobs with the sstat command. For example:
sstat --format=JobId,AveCPU,AveRSS,MaxRSS -j <jobid>
This will show average CPU time, average and maximum memory consumption of all tasks in the running job.
'sstat -e' command shows a list of fields that can be specified with the '--format' option.
Interactive access to running jobs
It is also possible to attach an interactive shell to a running job with command:
srun --jobid=<jobid> --overlap --pty /bin/bash
Commands like 'top' show you the most busy processes on the node. To exit 'top' type 'q'.
To monitor your GPU processes use the command 'nvidia-smi'.
Job Feedback
You get feedback on resource usage and job efficiency for completed jobs with the command:
seff <jobid>
Example Output:
============================= JOB FEEDBACK =============================
Job ID: 12345678
Cluster: helix
User/Group: hd_ab123/hd_hd
State: COMPLETED (exit code 0)
Nodes: 2
Cores per node: 64
CPU Utilized: 3-04:11:46
CPU Efficiency: 97.90% of 3-05:49:52 core-walltime
Job Wall-clock time: 00:36:29
Memory Utilized: 432.74 GB (estimated maximum)
Memory Efficiency: 85.96% of 503.42 GB (251.71 GB/node)
Explanation:
- Nodes: Number of allocated nodes for the job.
- Cores per node: Number of physical cores per node allocated for the job.
- CPU Utilized: Sum of utilized core time.
- CPU Efficiency: 'CPU Utilized' with respect to core-walltime (= 'Nodes' x 'Cores per node' x 'Job Wall-clock time') in percent.
- Job Wall-clock time: runtime of the job.
- Memory Utilized: Sum of memory used. For multi node MPI jobs the sum is only correct when srun is used instead of mpirun.
- Memory Efficiency: 'Memory Utilized' with respect to total allocated memory for the job.
Accounting
Jobs are billed for allocated CPU cores, memory and GPUs.
To see the accounting data of a specific job:
sacct -j <jobid> --format=user,jobid,account,nnodes,ncpus,time,elapsed,AllocTRES%50
To retrieve the job history for a specific user for a certain time frame:
sacct -u <user> -S 2022-08-20 -E 2022-08-30 --format=user,jobid,account,nnodes,ncpus,time,elapsed,AllocTRES%50
Overview about free resources
On the login nodes the following command shows what resources are available for immediate use:
sinfo_t_idle