Energy Efficient Cluster Usage: Difference between revisions

From bwHPC Wiki
Jump to navigation Jump to search
(Restructured content and added more advice)
 
Line 1: Line 1:
Poor job efficiency means that hardware resources are wasted and a similar overall result could have been achieved using fewer hardware resources, leaving those for other jobs and reducing the queue wait time for all users.
= Introduction =
Efficient cluster usage means choosing optimal values for job resources:
* CPU cores
* GPUs
* Memory
* (temporary) storage
* Time




__TOC__
Energy consumption of data centers has been increasing continuously throughout the last decade. In 2020, the energy consumption of all data centers in Germany amounted to around [https://www.bundestag.de/resource/blob/863850/423c11968fcb5c9995e9ef9090edf9e6/WD-8-070-21-pdf-data.pdf 3 percent] of the total electricity produced. Accompanying this large energy consumption are large-scale emissions of CO2 to the atmosphere and thus significant contributions to climate change.
To illustrate this, an average compute job running on a single node for one day may easily consume 10 kWh or even more. That translates roughly to brewing 700 cups of coffee.
Assuming that a typical bwHPC cluster has a few hundred compute nodes, this amounts to the energy consumption of a village for each cluster.


== Motivation ==
Although a large amount of this energy consumption is an intrinsic requirement of running large HPC clusters (even when it's processors are idle, a cluster uses a lot of energy), efficient use of the available resources is important. Using as many resources as possible does not make a power user. Using them wisely does.
'''User perspective'''
In the following, a basic introduction to some of the most important aspects of energy-efficient HPC usage from a user perspective is given.


Short waiting times including short cycles of trial and error and fast results. The lower the job efficiency the longer the waiting times relative to the shortest possible time.
We can generally distinguish three tasks when optimizing for running HPC jobs efficiently.


'''Energy perspective'''
→ What do I want to do and why do I need an HPC Cluster for it?


Energy consumption of data centers has been increasing continuously throughout the last decade. In 2020, the energy consumption of all data centers in Germany amounted to around [https://www.bundestag.de/resource/blob/863850/423c11968fcb5c9995e9ef9090edf9e6/WD-8-070-21-pdf-data.pdf 3 percent] of the total electricity produced. Accompanying this large energy consumption are large-scale emissions of CO2 to the atmosphere and thus significant contributions to climate change.
→ How many and which kind of hardware resources do I require for it?
To illustrate this, an average compute job running on a single node for one day may easily consume 10 kWh or even more. That translates roughly to brewing 700 cups of coffee.
Assuming that a typical bwHPC cluster has a few hundred compute nodes, this amounts to the energy consumption of a village for each cluster.
Although a large amount of this energy consumption is an intrinsic requirement of running large HPC clusters (even when it's processors are idle, a cluster uses a lot of energy), efficient use of the available resources is important.


Something to keep in mind:
→ How do I optimize my code to use these resources most efficiently?
‎<blockquote>Using as many resources as possible does not make a power user. Using them wisely does.‎</blockquote>


== Recommendations ==
= What do I want to do and why do I need an HPC Cluster for it? =

The bwHPC clusters are used to almost full capacity, and running a job on an HPC node consumes a lot of energy, as shown above.
Therefore, users are requested to run only necessary jobs.

Please consider testing new setups and their output for validity prior to submitting jobs that require lots of resources. This also includes projects where a lot of (smaller) similar jobs are submitted.

Make sure to double-check your jobs prior to the submission, as having to discard the output data of an HPC project due to faulty input files is wasting a lot of computational resources.

Finally, identifying the specific resource requirements for a given job is important to allocate the optimal amount for your compute job, and to decide if an HPC cluster is needed at all.

= How many and which kind of hardware resources do I require for it =


Resource allocation is a crucial part when working on an HPC cluster.
As this is dependent on both the job as well as the specific cluster hardware and architecture available.

'''A small number of jobs and few resources'''

&rarr; Submit to the scheduler. No extended testing and resource scaling analysis are needed.

'''Medium-sized projects'''

&rarr; Run only necessary jobs: Please consider testing new setups and their output for validity prior to submitting a huge amount of similar jobs

&rarr; Start small: Run your problem on a small set of resources first.

&rarr; Use the proper tools for development: If you develop your own code, please use the proper tools for debugging and parallel performance analysis. See: [[Development#Documentation_in_the_Wiki|Development]].

&rarr; A look at the job feedback can help you determine if you are using the cluster efficiently


'''Large projects'''

&rarr; Same approach as for medium-sized projects.

&rarr; Run a scaling analysis for your project with regard to how many resources work best. See: [[Scaling]].


'''Many short jobs'''

&rarr; Handling via the scheduler is inefficient.

&rarr; Simple parallelization by hand is advisable. See: A basic introduction to [[Development/Parallel_Programming | Parallel Programming]].

= How do I optimize my code to use these resources most efficiently? =

The above recommendations will help use the cluster resources more efficiently.
Regarding software development, power efficiency correlates obviously heavily with '''computing performance''', but also with memory usage, i.e. the amount of memory used, but also memory efficiency.

Here, we have gathered a few results based on other research:
&rarr; Use an efficient programming language such as Rust, C, and C++ -- well any compiled language. Do not use any interpreted language like Perl or Python. Since Machine Learning is a hot topic, this deserves a few words: Any ML-Python code using Tensorflow or other libraries will make heavy usage of NumPy and other math packages, which will use C-based implementations. Please make sure, you use the provided Python modules, which are optimized to use Intel MKL and other mathematical libraries.


* Use the '''job monitoring''' options of your respective cluster to see the job efficiency and ways to improve it.
* '''Test''' new setups first before submitting a lot of similar jobs or resource demanding jobs.
** Run a single job first before sending many.
** Run a simplified problem on a small number of parallel entities (be it processes or threads) first before requesting many resources.
** Run a time intensive task with a short runtime first to see if it already fails in the first minutes.
* Follow the best practices of your chosen tool, software or programming language and choose the most efficient algorithms for the given problem. There are several places where you might find related documentation:
** Software Module help.
** Software page of your cluster.
** Pages linked at the [[Development]] page. For example information about debugging, performance analysis, specific programming languages etc. . &rarr; Use an efficient programming language such as Rust, C, and C++ -- well any compiled language. Do not use any interpreted language like Perl or Python. Since Machine Learning is a hot topic, this deserves a few words: Any ML-Python code using Tensorflow or other libraries will make heavy usage of NumPy and other math packages, which will use C-based implementations. Please make sure, you use the provided Python modules, which are optimized to use Intel MKL and other mathematical libraries.
Further reading:
Further reading:
Rui Pereira, et al: "''Energy efficiency across programming languages: how do energy, time, and memory relate?''", SLE 2017: Proc. of the 10th ACM SIGPLAN Int. Conf. on SW Language Eng., Oct. 2017, pp. 256–267, [https://doi.org/10.1145/3136014.3136031 doi:10.1145/3136014.3136031]
Rui Pereira, et al: "''Energy efficiency across programming languages: how do energy, time, and memory relate?''", SLE 2017: Proc. of the 10th ACM SIGPLAN Int. Conf. on SW Language Eng., Oct. 2017, pp. 256–267, [https://doi.org/10.1145/3136014.3136031 doi:10.1145/3136014.3136031]
* If you have a task that can be scaled up, please consider a [[Scaling | '''scaling analysis''']].
* Analyse '''memory access patterns''': For small tight loops checking for locks, use the <code>pause</code> instruction.


== Things to avoid ==
&rarr; Analyse memory access patterns

&rarr; For small tight loops checking for locks, use the <code>pause</code> instruction.


* Poor choice of resources compared to the size of the nodes leaves part of the node blocked, but doing nothing:
= Summary: General Recommendations =
** Too much (un-needed) memory or disk space requested
* Many small jobs with a short runtime (seconds in extreme cases). A job should run at least 10 minutes.
* When a node has 256 gb memory but only 236 gb are usable (see Hardware table of your cluster) then requesting 256 gb memory needs two nodes.
* GPU: Do not ask for a specific gpu type when your code would be fitting for any type.
* More cores used for a single mpi/openmp parallel computation than useful.
* Writing temporary files to global filesystems when a ram disk or local disk can be used.
* Do not use more parallel processes than there are actual, reasonable parallel tasks. Examples:
** 4 datasets with values for the same 1000 genes each. Method xx shall be used per gene. This operation needs 10 seconds per gene.
*** Case 1: Provide 64 single threaded cores within one job and use one process/thread per gene: This creates a large overhead as only 64 processes can run in parallel while all 5000 processes try to get computing time so that a process might run for 5 seconds and then makes room for another process that also isn't able to finish because another process comes in between.
*** Case 2: Send 1 job per gene so that each job uses method xx on this gene in all 4 datasets: This creates a large overhead as each job only needs 50 seconds while there is a thousand times the overhead of creating and finishing a job.
*** Case 3: Provide 64 cores in one job. Each dataset uses 16 cores. Each core needs to process 1000/16 =~ 63 genes. This needs 63*10 seconds
= 10.5 minutes job runtime with just the overhead of creating a single job and 16 processes without switching between processes.
** &rarr; Simple parallelization by hand is advisable. See: A basic introduction to [[Development/Parallel_Programming | Parallel Programming]].


== Fair Share and Scheduler ==
* Choose the most '''efficient algorithms''' for the given problem.
Influence of Efficiency on Fair Share and Scheduler:
* Run only '''necessary''' jobs: Please consider testing new setups and their output for validity prior to submitting a huge amount of similar jobs.
* '''Fair Share value:'''
* Start '''small''': Run your problem on a small number of parallel entities (be it processes or threads) first.
*: The fair share value represents your priority on the cluster. On a busy cluster a low priority leads to longer waiting times as other users with a higher priority have a higher chance of getting free resource slots. The fair share value declines when a lot of cluster resources were used recently. Used is defined as follows:
* '''Estimate''' the runtime of the parallel job as '''exactly''' as possible to increase the efficiency of the scheduling of the whole system.
*:* Requested resources: 4 gpus for 2 hours
* Use the proper tools for development: If you develop your own code, please use the proper tools for debugging and parallel performance analysis. More information is available on the bwHPC Wiki.
*:* Actual resource usage: 1 gpu and job finishes successfully after 1 hour.
* A look at the '''job feedback''' can help you determine if you are using the cluster efficiently.
*:* Used resources as considered by the fair share value: 4 gpus for 1 hour because the three idle gpus couldn't be used by any other cluster used as they were blocked by this job.
* '''Job scheduler:'''
*: The longer the requested runtime and the more resources are needed in that time the harder it is to find a fitting timeframe where these resources are free.

Latest revision as of 09:51, 14 July 2026

Poor job efficiency means that hardware resources are wasted and a similar overall result could have been achieved using fewer hardware resources, leaving those for other jobs and reducing the queue wait time for all users. Efficient cluster usage means choosing optimal values for job resources:

  • CPU cores
  • GPUs
  • Memory
  • (temporary) storage
  • Time


Motivation

User perspective

Short waiting times including short cycles of trial and error and fast results. The lower the job efficiency the longer the waiting times relative to the shortest possible time.

Energy perspective

Energy consumption of data centers has been increasing continuously throughout the last decade. In 2020, the energy consumption of all data centers in Germany amounted to around 3 percent of the total electricity produced. Accompanying this large energy consumption are large-scale emissions of CO2 to the atmosphere and thus significant contributions to climate change. To illustrate this, an average compute job running on a single node for one day may easily consume 10 kWh or even more. That translates roughly to brewing 700 cups of coffee. Assuming that a typical bwHPC cluster has a few hundred compute nodes, this amounts to the energy consumption of a village for each cluster. Although a large amount of this energy consumption is an intrinsic requirement of running large HPC clusters (even when it's processors are idle, a cluster uses a lot of energy), efficient use of the available resources is important.

Something to keep in mind:

Using as many resources as possible does not make a power user. Using them wisely does.‎

Recommendations

  • Use the job monitoring options of your respective cluster to see the job efficiency and ways to improve it.
  • Test new setups first before submitting a lot of similar jobs or resource demanding jobs.
    • Run a single job first before sending many.
    • Run a simplified problem on a small number of parallel entities (be it processes or threads) first before requesting many resources.
    • Run a time intensive task with a short runtime first to see if it already fails in the first minutes.
  • Follow the best practices of your chosen tool, software or programming language and choose the most efficient algorithms for the given problem. There are several places where you might find related documentation:
    • Software Module help.
    • Software page of your cluster.
    • Pages linked at the Development page. For example information about debugging, performance analysis, specific programming languages etc. . → Use an efficient programming language such as Rust, C, and C++ -- well any compiled language. Do not use any interpreted language like Perl or Python. Since Machine Learning is a hot topic, this deserves a few words: Any ML-Python code using Tensorflow or other libraries will make heavy usage of NumPy and other math packages, which will use C-based implementations. Please make sure, you use the provided Python modules, which are optimized to use Intel MKL and other mathematical libraries.

Further reading: Rui Pereira, et al: "Energy efficiency across programming languages: how do energy, time, and memory relate?", SLE 2017: Proc. of the 10th ACM SIGPLAN Int. Conf. on SW Language Eng., Oct. 2017, pp. 256–267, doi:10.1145/3136014.3136031

  • If you have a task that can be scaled up, please consider a scaling analysis.
  • Analyse memory access patterns: For small tight loops checking for locks, use the pause instruction.

Things to avoid

  • Poor choice of resources compared to the size of the nodes leaves part of the node blocked, but doing nothing:
    • Too much (un-needed) memory or disk space requested
  • Many small jobs with a short runtime (seconds in extreme cases). A job should run at least 10 minutes.
  • When a node has 256 gb memory but only 236 gb are usable (see Hardware table of your cluster) then requesting 256 gb memory needs two nodes.
  • GPU: Do not ask for a specific gpu type when your code would be fitting for any type.
  • More cores used for a single mpi/openmp parallel computation than useful.
  • Writing temporary files to global filesystems when a ram disk or local disk can be used.
  • Do not use more parallel processes than there are actual, reasonable parallel tasks. Examples:
    • 4 datasets with values for the same 1000 genes each. Method xx shall be used per gene. This operation needs 10 seconds per gene.
      • Case 1: Provide 64 single threaded cores within one job and use one process/thread per gene: This creates a large overhead as only 64 processes can run in parallel while all 5000 processes try to get computing time so that a process might run for 5 seconds and then makes room for another process that also isn't able to finish because another process comes in between.
      • Case 2: Send 1 job per gene so that each job uses method xx on this gene in all 4 datasets: This creates a large overhead as each job only needs 50 seconds while there is a thousand times the overhead of creating and finishing a job.
      • Case 3: Provide 64 cores in one job. Each dataset uses 16 cores. Each core needs to process 1000/16 =~ 63 genes. This needs 63*10 seconds

= 10.5 minutes job runtime with just the overhead of creating a single job and 16 processes without switching between processes.

Fair Share and Scheduler

Influence of Efficiency on Fair Share and Scheduler:

  • Fair Share value:
    The fair share value represents your priority on the cluster. On a busy cluster a low priority leads to longer waiting times as other users with a higher priority have a higher chance of getting free resource slots. The fair share value declines when a lot of cluster resources were used recently. Used is defined as follows:
    • Requested resources: 4 gpus for 2 hours
    • Actual resource usage: 1 gpu and job finishes successfully after 1 hour.
    • Used resources as considered by the fair share value: 4 gpus for 1 hour because the three idle gpus couldn't be used by any other cluster used as they were blocked by this job.
  • Job scheduler:
    The longer the requested runtime and the more resources are needed in that time the harder it is to find a fitting timeframe where these resources are free.