MCPcopy Create free account
hub / github.com/mlco2/codecarbon / get_cpu_details

Method get_cpu_details

codecarbon/core/cpu.py:825–852  ·  view source on GitHub ↗

Fetches the CPU Energy Deltas by fetching values from RAPL files

(self, duration: Time)

Source from the content-addressed store, hash-verified

823 self._create_rapl_files(domain_map, found_main_readable)
824
825 def get_cpu_details(self, duration: Time) -> Dict:
826 """
827 Fetches the CPU Energy Deltas by fetching values from RAPL files
828 """
829 cpu_details = {}
830 try:
831 for rapl_file in self._rapl_files:
832 rapl_file.delta(duration)
833
834 for rapl_file in self._rapl_files:
835 logger.debug(rapl_file)
836 cpu_details[rapl_file.name] = rapl_file.energy_delta.kWh
837 # We fake the name used by Power Gadget when using RAPL
838 if "Energy" in rapl_file.name:
839 cpu_details[rapl_file.name.replace("Energy", "Power")] = (
840 rapl_file.power.W
841 )
842 except Exception as e:
843 logger.info(
844 "\tRAPL - Unable to read Intel RAPL files at %s\n \
845 Exception occurred %s",
846 self._rapl_files,
847 e,
848 exc_info=True,
849 )
850 self._cpu_details = cpu_details
851 logger.debug("get_cpu_details %s", self._cpu_details)
852 return cpu_details
853
854 def get_static_cpu_details(self) -> Dict:
855 """

Callers 5

test_intel_raplMethod · 0.95
_get_power_from_cpusMethod · 0.45
_get_energy_from_cpusMethod · 0.45

Calls 1

deltaMethod · 0.45

Tested by 1

test_intel_raplMethod · 0.76