Calculation methodology¤
This page describes the methodology used to estimate the energy usage and carbon emissions of compute jobs.
Gathering Compute Resources¤
Information about the compute job and executing node is gathered from the workload scheduler. For Imperial's CX3 and HX1 systems, this is PBS.
Internally, carbon performs a subprocess call to the PBS command qstat and parses the result.
Therefore, only jobs accessible to qstat can be analysed by carbon.
Currently, this means that only jobs which completed in the past two weeks (or jobs in progress) may be analysed.
Estimating Energy Consumption¤
The energy consumed by a job is estimated following the methodology behind the Green Algorithms project, led by Loïc Lannelongue at the University of Cambridge (1). This involves estimating the energy consumed using the compute resources assigned/used by the job, and information about the power draw of compute components provided by the component manufacturers. An additional factor is included in the calculation which accounts for the power usage effectiveness (PUE) of the data centre.
The following equation is used to estimate energy consumption (adapted from (1)):
where is the runtime of the compute job, is the per-core power draw of the CPU(s), is the usage factor of the CPU cores (which can vary between 0 and , where is the number of cores utilised by the job), is the per-component power draw of the GPU(s), is the number of GPUs employed, is the power draw of the memory (per GB), is the amount of memory allocated to the job (in GB), and is the PUE of the data center.
To estimate values for the power draw of the processors ( and ), the thermal design power (TDP) of the component is used.
TDPs are sourced from the website of the relevant manufacturer (see Sources).
The PBS workload manager used for Imperial's CX3 and HX1 systems is configured to allow the sharing of nodes between multiple jobs (there is no node exclusivity).
This holds also for the CPUs, with cores being able to be distributed among concurrent jobs.
The TDP of the full CPU component is therefore divided by the number of cores to yield an approximater per-core power draw, .
For the CPU, the workload manager tracks the utilisation of the cores, , over the job runtime.
This is used to scale the energy consumption due to the CPU.
(Note that PBS reports the variable cput, which is the CPU core-time of a job, accounting for utilisation. This variable, equivalent to , is used in the code, slightly changing the form of the energy calculation equation used in-code from that shown above).
For the GPU, exclusive use of the component by a job is assumed, so the full TDP is used for estimating power draw, . Since the workload managed is not configured to track the utilisation of the GPU, we assume 100% utilisation over the runtime of the job.
To estimate the power draw of memory (RAM), we follow the methodology laid out in (1). In that work, the authors describe how the power draw of memory is mainly dependent on the total quantity mobilised, rather than the amount actively in use or the nature of the workload (1, 2). Therefore, the amount of memory allocated to a job is used to determine the power draw due to memory, using a per-GB power of 0.3725 GB/W (1).
The method of estimating energy consumption based on compute resources assigned to the job may be compared to two alternative options (3, 4):
- Hardware-based measurements (e.g., a physical power meter attached to the compute node or rack).
- Software tools (e.g., Perf, PowerStat, CodeCarbon, which typically make use of Intel's RAPL interface under the hood).
Measuring energy consumption directly via hardware tools will generally lead to the most accurate values, with software tools being less accurate but typically more practical (3). Compared to both these methods, estimating energy consumption based on compute resource usage will tend to be even less accurate. However, it has two major practical advantages that motivated the adoption of this approach for carbon:
- It is significantly less 'invasive', requiring no installation of additional hardware or software tools on the compute nodes/racks of the HPC cluster.
- It can much more straightforwardly estimate the energy consumption associated with a particular user/process in a situation were a compute node may be shared between multiple users/processes.
In order to validate this approach, I am currently in the process of collating energy consumption estimates using carbon, with the aim of comparing/benchmarking these against energy usage statistics provided by the data center hosting the CX3 and HX1 clusters.
Estimating Emissions¤
An estimate of the carbon emissions associated with a compute job () may be calculated by multiplying the estimated energy consumption of the job (), by the carbon intensity of the electrical energy ():
is dependent on the mixture of generation technologies used to produce the electrical energy supplied to the HPC cluster, and varies by time and location. For clusters based in the UK, we can use the Carbon Intensity API, run by the National Energy Systems Operator, to fetch for a given region and time. The region ID to use is set in the carbon config file (see a list of IDs here). The start time of the job is used for the timestamp for which is fetched.
Note that only CO2 emissions from electricity generation are reported by the API, meaning that other greenhouse gas emissions are neglected, along with other emissions due to indirect effects such as changes in land use.
The API call can be skipped in favour of a hardcoded carbon intensity using the flag --average-intensity.
This value (137 CO2/kWh) is based on an average of the UK's carbon intensity over 2023 (149 CO2/kWh) and 2024 (125 CO2/kWh) (see Sources).
ToDo: Link to separate doc with details about renewable energy certification (REGOs?).
References¤
- L. Lannelongue, J. Grealey, M. Inouye, Green Algorithms: Quantifying the Carbon Footprint of Computation, Advanced Science, 02 May 2021
- A. Karyakin, K. Salem, An Analysis of Memory Power Consumption in Database Systems, Proceedings of the 13th International Workshop on Data Management on New Hardware, 15 May 2017
- L. Lannelongue, M. Inouye, Carbon footprint estimation for computational research, Nature Reviews Methods Primers, 16 February 2023
- U. Asgher, T. Malik, Evaluating Hardware and Software Power Measurement Tools: Assessing Accuracy in Measuring Application Energy Consumption for Data-Parallel Workloads, Proceedings of the Fourth International Conference on Innovations in Computing Research, 27 June 2025