Energy Efficient Cluster Usage: Difference between revisions
H Schumacher (talk | contribs) (Restructured content and added more advice) |
|||
| (23 intermediate revisions by 6 users not shown) | |||
| 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. |
|||
= General Issue with Energy Efficiency = |
|||
Efficient cluster usage means choosing optimal values for job resources: |
|||
* CPU cores |
|||
* GPUs |
|||
* Memory |
|||
* (temporary) storage |
|||
* Time |
|||
You are all aware of the rising energy costs and you are certainly careful to economize your energy |
|||
consumption at home. |
|||
But are you aware of the energy consumed by your computational jobs? |
|||
| ⚫ | |||
even more. |
|||
__TOC__ |
|||
That translates roughly to one of the following activities: |
|||
* toasting about 1330 slices of toast in a toaster |
|||
* continuously blow-drying your hair for about 10 hours |
|||
* actively working on a laptop for about 500 hours |
|||
* brewing 700 cups of coffee |
|||
== Motivation == |
|||
Besides energy costs, even this single job alone |
|||
'''User perspective''' |
|||
will also contribute to climate change by adding |
|||
around 5 kg of CO<sub>2</sub> to the atmosphere (based on the average German power mix) |
|||
which is roughly equivalent to driving a distance of 30 km by car. |
|||
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. |
|||
You get the point: Please always keep this in mind |
|||
when submitting tens or even hundreds of jobs to |
|||
the queue, just like you do when switching on your |
|||
electrical devices at home. Also, please always think |
|||
carefully about how many resources your jobs |
|||
really need and whether your application really |
|||
benefits from allocating more cores for the jobs. |
|||
Application speedup is often limited and does not |
|||
scale linearly with the number of dedicated cores. But |
|||
energy consumption usually does ... |
|||
'''Energy perspective''' |
|||
| ⚫ | |||
If in doubt, just ask. |
|||
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. |
|||
= General recommendations = |
|||
| ⚫ | |||
* Choose the most '''efficient algorithms''' for the given problem |
|||
Assuming that a typical bwHPC cluster has a few hundred compute nodes, this amounts to the energy consumption of a village for each cluster. |
|||
* Run only '''necessary''' jobs: Please consider testing new setups and their output for validity prior to submitting a huge amount of similar jobs |
|||
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. |
|||
| ⚫ | |||
* '''Estimate''' the runtime of the parallel job as '''exactly''' as possible to increase efficiency of the scheduling of the whole system |
|||
* 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. |
|||
* A look at the '''job feedback''' can help you determine if you are using the cluster efficiently |
|||
Something to keep in mind: |
|||
= Code development recommendations = |
|||
| ⚫ | |||
= Specific Scientific recommendations = |
|||
== 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 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, [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 == |
|||
* 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. |
|||
** → Simple parallelization by hand is advisable. See: A basic introduction to [[Development/Parallel_Programming | Parallel Programming]]. |
|||
== 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. |
|||
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
pauseinstruction.
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
- 4 datasets with values for the same 1000 genes each. Method xx shall be used per gene. This operation needs 10 seconds per gene.
= 10.5 minutes job runtime with just the overhead of creating a single job and 16 processes without switching between processes.
- → Simple parallelization by hand is advisable. See: A basic introduction to Parallel Programming.
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.
- 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:
- 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.