From 2d99513cdf004becb022baab611c72a913345091 Mon Sep 17 00:00:00 2001 From: LuisBlanche Date: Fri, 20 Dec 2024 12:55:06 +0100 Subject: [PATCH 01/15] feat: :sparkles: create macmon class for Mac monitoring --- .gitignore | 1 + codecarbon/core/macmon.py | 141 ++++++++++++++++++++++++++++ tests/test_data/mock_macmon_log.txt | 10 ++ tests/test_macmon.py | 39 ++++++++ 4 files changed, 191 insertions(+) create mode 100644 codecarbon/core/macmon.py create mode 100644 tests/test_data/mock_macmon_log.txt create mode 100644 tests/test_macmon.py diff --git a/.gitignore b/.gitignore index eee478f7a..2e4b16485 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ __pycache__/ *$py.class *intel_power_gadget_log.csv *powermetrics_log.txt +*macmon_log.txt !tests/test_data/mock* .codecarbon.config diff --git a/codecarbon/core/macmon.py b/codecarbon/core/macmon.py new file mode 100644 index 000000000..f3342168a --- /dev/null +++ b/codecarbon/core/macmon.py @@ -0,0 +1,141 @@ +import json +import os +import shutil +import subprocess +import sys +from typing import Dict + +import numpy as np + +from codecarbon.core.util import detect_cpu_model +from codecarbon.external.logger import logger + + +def is_macmon_available() -> bool: + try: + macmon = MacMon() + return macmon._log_file_path is not None + except Exception as e: + msg = "Not using macmon, exception occurred while instantiating" + logger.debug(f"{msg} macmon : {e}") + return False + + +class MacMon: + """ + A class to interact with and retrieve power metrics on Apple Silicon devices using + the `macmon` command-line tool. + + This class implements a singleton pattern for the macmon process to avoid + running multiple instances simultaneously. + + Methods: + -------- + __init__(output_dir: str = ".", n_points=10, interval=100, + log_file_name="macmon_log.txt"): + Initializes the Applemacmon instance, setting up the log file path, + system info, and other configurations. + + get_details() -> Dict: + Parses the log file generated by `macmon` and returns a dictionary + containing the average CPU and GPU power consumption and energy deltas. + + start() -> None: + Starts the macmon process if not already running. + """ + + _osx_silicon_exec = "macmon" + + def __init__( + self, + output_dir: str = ".", + n_points=10, + interval=100, + log_file_name="macmon_log.txt", + ) -> None: + # Only initialize once + self._log_file_path = os.path.join(output_dir, log_file_name) + self._system = sys.platform.lower() + self._n_points = n_points + self._interval = interval + self._setup_cli() + self._process = None + + def _setup_cli(self) -> None: + """ + Setup cli command to run macmon + """ + if self._system.startswith("darwin"): + cpu_model = detect_cpu_model() + if cpu_model.startswith("Apple"): + if shutil.which(self._osx_silicon_exec): + self._cli = self._osx_silicon_exec + else: + msg = f"Macmon executable not found on {self._system}, install with `brew install macmon` or checkout https://github.com/vladkens/macmon for installation instructions" + raise FileNotFoundError(msg) + else: + raise SystemError("Platform not supported by MacMon") + + def _log_values(self) -> None: + """ + Logs output from Macmon to a file. If a macmon process is already + running, it will use the existing process instead of starting a new one. + """ + returncode = None + if self._system.startswith("darwin"): + # Run the MacMon command and capture its output + cmd = [ + "macmon", + "-i", + str(self._interval), + "pipe", + "-s", + str(self._n_points), + ] + with open(self._log_file_path, "w") as f: + returncode = subprocess.call(cmd, universal_newlines=True, stdout=f, text=True) + else: + return None + if returncode != 0: + logger.warning("Returncode while logging power values using " + f"Macmon: {returncode}") + return + + def get_details(self) -> Dict: + """ + Fetches the CPU Power Details by fetching values from a logged csv file + in _log_values function + """ + self._log_values() + details = dict() + try: + cpu_power_list = [] + gpu_power_list = [] + ram_power_list = [] + + with open(self._log_file_path) as f: + for line in f: + j = json.loads(line) + cpu_power_list.append(float(j["cpu_power"])) + gpu_power_list.append(float(j["gpu_power"])) + ram_power_list.append(float(j["ram_power"])) + + details["CPU Power"] = np.mean([power / 1000 for power in cpu_power_list]) + details["CPU Energy Delta"] = np.sum( + [(self._interval / 1000) * (power / 1000) for power in cpu_power_list] + ) + details["GPU Power"] = np.mean([power / 1000 for power in gpu_power_list]) + details["GPU Energy Delta"] = np.sum( + [(self._interval / 1000) * (power / 1000) for power in gpu_power_list] + ) + details["Ram Power"] = np.mean([power / 1000 for power in ram_power_list]) + details["Ram Energy Delta"] = np.sum( + [(self._interval / 1000) * (power / 1000) for power in ram_power_list] + ) + except Exception as e: + msg = f"Unable to read macmon logged file at {self._log_file_path}\n" f"Exception occurred {e}" + logger.info(msg, exc_info=True) + return details + + def start(self) -> None: + # Start is handled in _log_values when needed + pass diff --git a/tests/test_data/mock_macmon_log.txt b/tests/test_data/mock_macmon_log.txt new file mode 100644 index 000000000..5f2986741 --- /dev/null +++ b/tests/test_data/mock_macmon_log.txt @@ -0,0 +1,10 @@ +{"temp":{"cpu_temp_avg":47.99754,"gpu_temp_avg":44.168976},"memory":{"ram_total":8589934592,"ram_usage":7016267776,"swap_total":6442450944,"swap_usage":5806751744},"ecpu_usage":[1221,0.059566148],"pcpu_usage":[2813,0.12654762],"gpu_usage":[396,0.052929282],"cpu_power":0.47729987,"gpu_power":0.025773834,"ane_power":0.0,"all_power":0.5030737,"sys_power":12.617373,"ram_power":0.0,"gpu_ram_power":0.0} +{"temp":{"cpu_temp_avg":47.99754,"gpu_temp_avg":44.834038},"memory":{"ram_total":8589934592,"ram_usage":7019053056,"swap_total":6442450944,"swap_usage":5806751744},"ecpu_usage":[1496,0.10201424],"pcpu_usage":[2434,0.11360246],"gpu_usage":[396,0.063834384],"cpu_power":0.43330622,"gpu_power":0.02971501,"ane_power":0.0,"all_power":0.46302122,"sys_power":12.617373,"ram_power":0.0,"gpu_ram_power":0.0} +{"temp":{"cpu_temp_avg":47.99754,"gpu_temp_avg":44.834038},"memory":{"ram_total":8589934592,"ram_usage":7019937792,"swap_total":6442450944,"swap_usage":5806751744},"ecpu_usage":[1261,0.10726784],"pcpu_usage":[2209,0.07984778],"gpu_usage":[396,0.054138985],"cpu_power":0.17238411,"gpu_power":0.023141222,"ane_power":0.0,"all_power":0.19552533,"sys_power":12.617373,"ram_power":0.0,"gpu_ram_power":0.0} +{"temp":{"cpu_temp_avg":47.99754,"gpu_temp_avg":44.834038},"memory":{"ram_total":8589934592,"ram_usage":7019937792,"swap_total":6442450944,"swap_usage":5806751744},"ecpu_usage":[1368,0.13209346],"pcpu_usage":[2653,0.085086405],"gpu_usage":[396,0.051508717],"cpu_power":0.1759564,"gpu_power":0.023062157,"ane_power":0.0,"all_power":0.19901855,"sys_power":12.617373,"ram_power":0.0,"gpu_ram_power":0.0} +{"temp":{"cpu_temp_avg":47.99754,"gpu_temp_avg":44.834038},"memory":{"ram_total":8589934592,"ram_usage":7019937792,"swap_total":6442450944,"swap_usage":5806751744},"ecpu_usage":[1561,0.13995293],"pcpu_usage":[2342,0.077804655],"gpu_usage":[396,0.05396843],"cpu_power":0.20275298,"gpu_power":0.023571063,"ane_power":0.0,"all_power":0.22632404,"sys_power":12.072607,"ram_power":0.0,"gpu_ram_power":0.0} +{"temp":{"cpu_temp_avg":47.99754,"gpu_temp_avg":44.834038},"memory":{"ram_total":8589934592,"ram_usage":7019937792,"swap_total":6442450944,"swap_usage":5806751744},"ecpu_usage":[1498,0.13700348],"pcpu_usage":[2471,0.0862776],"gpu_usage":[396,0.05373454],"cpu_power":0.21767727,"gpu_power":0.03300677,"ane_power":0.0,"all_power":0.25068402,"sys_power":12.072607,"ram_power":0.0,"gpu_ram_power":0.0} +{"temp":{"cpu_temp_avg":47.99754,"gpu_temp_avg":44.834038},"memory":{"ram_total":8589934592,"ram_usage":7019937792,"swap_total":6442450944,"swap_usage":5806751744},"ecpu_usage":[1513,0.28408676],"pcpu_usage":[2005,0.17747135],"gpu_usage":[396,0.057192028],"cpu_power":0.86930436,"gpu_power":0.029238673,"ane_power":0.0,"all_power":0.89854306,"sys_power":12.072607,"ram_power":0.0,"gpu_ram_power":0.0} +{"temp":{"cpu_temp_avg":47.99754,"gpu_temp_avg":44.834038},"memory":{"ram_total":8589934592,"ram_usage":7019937792,"swap_total":6442450944,"swap_usage":5806751744},"ecpu_usage":[1478,0.16347156],"pcpu_usage":[2230,0.083416276],"gpu_usage":[396,0.050722033],"cpu_power":0.22681558,"gpu_power":0.020034816,"ane_power":0.0,"all_power":0.2468504,"sys_power":12.072607,"ram_power":0.0,"gpu_ram_power":0.0} +{"temp":{"cpu_temp_avg":46.749672,"gpu_temp_avg":44.735157},"memory":{"ram_total":8589934592,"ram_usage":7017316352,"swap_total":6442450944,"swap_usage":5806751744},"ecpu_usage":[1522,0.22398606],"pcpu_usage":[2076,0.10601956],"gpu_usage":[396,0.052908726],"cpu_power":0.5067222,"gpu_power":0.014275403,"ane_power":0.0,"all_power":0.52099764,"sys_power":12.072607,"ram_power":0.0,"gpu_ram_power":0.0} +{"temp":{"cpu_temp_avg":46.749672,"gpu_temp_avg":44.735157},"memory":{"ram_total":8589934592,"ram_usage":7012958208,"swap_total":6442450944,"swap_usage":5806751744},"ecpu_usage":[1756,0.11604428],"pcpu_usage":[1914,0.13429697],"gpu_usage":[396,0.09375177],"cpu_power":0.7002688,"gpu_power":0.099837735,"ane_power":0.0,"all_power":0.8001065,"sys_power":12.072607,"ram_power":0.0,"gpu_ram_power":0.0} diff --git a/tests/test_macmon.py b/tests/test_macmon.py new file mode 100644 index 000000000..9b0c81ee3 --- /dev/null +++ b/tests/test_macmon.py @@ -0,0 +1,39 @@ +import os +import unittest +import unittest.result +from unittest import mock + +import pytest + +from codecarbon.core.macmon import MacMon, is_macmon_available + + +class TestMacMon(unittest.TestCase): + @pytest.mark.integ_test + def test_macmon(self): + if is_macmon_available(): + power_gadget = MacMon( + output_dir=os.path.join(os.path.dirname(__file__), "test_data"), + log_file_name="mock_macmon_log.txt", + ) + details = power_gadget.get_details() + assert len(details) > 0 + + # @pytest.mark.integ_test + @mock.patch("codecarbon.core.macmon.MacMon._log_values") + @mock.patch("codecarbon.core.macmon.MacMon._setup_cli") + def test_get_details(self, mock_setup, mock_log_values): + expected_details = { + "CPU Power": 0.3146, + "CPU Energy Delta": 0.3146, + "GPU Power": 0.0386, + "GPU Energy Delta": 0.0386, + } + if is_macmon_available(): + macmon = MacMon( + output_dir=os.path.join(os.path.dirname(__file__), "test_data"), + log_file_name="mock_macmon_log.txt", + ) + cpu_details = macmon.get_details() + + self.assertDictEqual(expected_details, cpu_details) From 31b8066b2976a9bb86c55035b925fcdd69ab7baa Mon Sep 17 00:00:00 2001 From: LuisBlanche Date: Fri, 20 Dec 2024 13:07:44 +0100 Subject: [PATCH 02/15] style: :art: black formatting --- codecarbon/core/macmon.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/codecarbon/core/macmon.py b/codecarbon/core/macmon.py index f3342168a..ffdf0b8ee 100644 --- a/codecarbon/core/macmon.py +++ b/codecarbon/core/macmon.py @@ -93,11 +93,15 @@ def _log_values(self) -> None: str(self._n_points), ] with open(self._log_file_path, "w") as f: - returncode = subprocess.call(cmd, universal_newlines=True, stdout=f, text=True) + returncode = subprocess.call( + cmd, universal_newlines=True, stdout=f, text=True + ) else: return None if returncode != 0: - logger.warning("Returncode while logging power values using " + f"Macmon: {returncode}") + logger.warning( + "Returncode while logging power values using " + f"Macmon: {returncode}" + ) return def get_details(self) -> Dict: @@ -132,7 +136,10 @@ def get_details(self) -> Dict: [(self._interval / 1000) * (power / 1000) for power in ram_power_list] ) except Exception as e: - msg = f"Unable to read macmon logged file at {self._log_file_path}\n" f"Exception occurred {e}" + msg = ( + f"Unable to read macmon logged file at {self._log_file_path}\n" + f"Exception occurred {e}" + ) logger.info(msg, exc_info=True) return details From d4f7fb15abae8017e59c882aa4c786ce5a71532b Mon Sep 17 00:00:00 2001 From: LuisBlanche Date: Fri, 20 Dec 2024 14:40:19 +0100 Subject: [PATCH 03/15] test: :white_check_mark: fix test and add cleanup --- tests/test_macmon.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/tests/test_macmon.py b/tests/test_macmon.py index 9b0c81ee3..99b233677 100644 --- a/tests/test_macmon.py +++ b/tests/test_macmon.py @@ -3,6 +3,7 @@ import unittest.result from unittest import mock +import numpy as np import pytest from codecarbon.core.macmon import MacMon, is_macmon_available @@ -12,28 +13,37 @@ class TestMacMon(unittest.TestCase): @pytest.mark.integ_test def test_macmon(self): if is_macmon_available(): + output_dir = os.path.join(os.path.dirname(__file__), "test_data") + log_file_path = os.path.join(output_dir, "macmon_log.txt") power_gadget = MacMon( - output_dir=os.path.join(os.path.dirname(__file__), "test_data"), - log_file_name="mock_macmon_log.txt", + output_dir=output_dir, + log_file_name="macmon_log.txt", ) details = power_gadget.get_details() + assert len(details) > 0 + # Cleanup + if os.path.exists(log_file_path): + os.remove(log_file_path) + # @pytest.mark.integ_test @mock.patch("codecarbon.core.macmon.MacMon._log_values") @mock.patch("codecarbon.core.macmon.MacMon._setup_cli") def test_get_details(self, mock_setup, mock_log_values): expected_details = { - "CPU Power": 0.3146, - "CPU Energy Delta": 0.3146, - "GPU Power": 0.0386, - "GPU Energy Delta": 0.0386, + "CPU Power": np.float64(0.000398248779), + "CPU Energy Delta": np.float64(0.000398248779), + "GPU Power": np.float64(3.21656683e-05), + "GPU Energy Delta": np.float64(3.2165668299999997e-05), + "Ram Power": np.float64(0.0), + "Ram Energy Delta": np.float64(0.0), } if is_macmon_available(): macmon = MacMon( output_dir=os.path.join(os.path.dirname(__file__), "test_data"), log_file_name="mock_macmon_log.txt", ) - cpu_details = macmon.get_details() + details = macmon.get_details() - self.assertDictEqual(expected_details, cpu_details) + self.assertDictEqual(expected_details, details) From 86df536eeee3a177def952410719f8d20e09c994 Mon Sep 17 00:00:00 2001 From: LuisBlanche Date: Sat, 21 Dec 2024 11:41:24 +0100 Subject: [PATCH 04/15] fix: :bug: fmacmon to append to log file + energy units fixed units to give out W and kWh --- codecarbon/core/macmon.py | 51 +++++++++++++++++---------------------- tests/test_macmon.py | 8 +++--- 2 files changed, 26 insertions(+), 33 deletions(-) diff --git a/codecarbon/core/macmon.py b/codecarbon/core/macmon.py index ffdf0b8ee..c77697a26 100644 --- a/codecarbon/core/macmon.py +++ b/codecarbon/core/macmon.py @@ -1,11 +1,10 @@ -import json import os import shutil import subprocess import sys from typing import Dict -import numpy as np +import pandas as pd from codecarbon.core.util import detect_cpu_model from codecarbon.external.logger import logger @@ -81,6 +80,8 @@ def _log_values(self) -> None: Logs output from Macmon to a file. If a macmon process is already running, it will use the existing process instead of starting a new one. """ + import multiprocessing + returncode = None if self._system.startswith("darwin"): # Run the MacMon command and capture its output @@ -92,10 +93,12 @@ def _log_values(self) -> None: "-s", str(self._n_points), ] - with open(self._log_file_path, "w") as f: - returncode = subprocess.call( - cmd, universal_newlines=True, stdout=f, text=True - ) + lock = multiprocessing.Lock() + with lock: + with open(self._log_file_path, "a") as f: # Open file in append mode + returncode = subprocess.call( + cmd, universal_newlines=True, stdout=f, text=True + ) else: return None if returncode != 0: @@ -112,29 +115,19 @@ def get_details(self) -> Dict: self._log_values() details = dict() try: - cpu_power_list = [] - gpu_power_list = [] - ram_power_list = [] - - with open(self._log_file_path) as f: - for line in f: - j = json.loads(line) - cpu_power_list.append(float(j["cpu_power"])) - gpu_power_list.append(float(j["gpu_power"])) - ram_power_list.append(float(j["ram_power"])) - - details["CPU Power"] = np.mean([power / 1000 for power in cpu_power_list]) - details["CPU Energy Delta"] = np.sum( - [(self._interval / 1000) * (power / 1000) for power in cpu_power_list] - ) - details["GPU Power"] = np.mean([power / 1000 for power in gpu_power_list]) - details["GPU Energy Delta"] = np.sum( - [(self._interval / 1000) * (power / 1000) for power in gpu_power_list] - ) - details["Ram Power"] = np.mean([power / 1000 for power in ram_power_list]) - details["Ram Energy Delta"] = np.sum( - [(self._interval / 1000) * (power / 1000) for power in ram_power_list] - ) + data = pd.read_json(self._log_file_path, lines=True) + details["CPU Power"] = data["cpu_power"].mean() + details["CPU Energy Delta"] = (self._interval / 1000) * ( + data["cpu_power"].astype(float) + ).sum() + details["GPU Power"] = data["gpu_power"].mean() + details["GPU Energy Delta"] = (self._interval / 1000) * ( + data["gpu_power"].astype(float) + ).sum() + details["Ram Power"] = data["ram_power"].mean() + details["Ram Energy Delta"] = (self._interval / 1000) * ( + data["ram_power"].astype(float) + ).sum() except Exception as e: msg = ( f"Unable to read macmon logged file at {self._log_file_path}\n" diff --git a/tests/test_macmon.py b/tests/test_macmon.py index 99b233677..cc9ba3f0c 100644 --- a/tests/test_macmon.py +++ b/tests/test_macmon.py @@ -32,10 +32,10 @@ def test_macmon(self): @mock.patch("codecarbon.core.macmon.MacMon._setup_cli") def test_get_details(self, mock_setup, mock_log_values): expected_details = { - "CPU Power": np.float64(0.000398248779), - "CPU Energy Delta": np.float64(0.000398248779), - "GPU Power": np.float64(3.21656683e-05), - "GPU Energy Delta": np.float64(3.2165668299999997e-05), + "CPU Power": np.float64(0.398248779), + "CPU Energy Delta": np.float64(0.398248779), + "GPU Power": np.float64(0.0321656683), + "GPU Energy Delta": np.float64(0.0321656683), "Ram Power": np.float64(0.0), "Ram Energy Delta": np.float64(0.0), } From a882b501c1c88f90660df8b8cd048d57b504c683 Mon Sep 17 00:00:00 2001 From: LuisBlanche Date: Sat, 21 Dec 2024 11:43:34 +0100 Subject: [PATCH 05/15] feat: :sparkles: better handling of "M*" chips and macmon supports macmon gets priority over powermetrics --- codecarbon/core/resource_tracker.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/codecarbon/core/resource_tracker.py b/codecarbon/core/resource_tracker.py index 4ae910852..33c4f64fb 100644 --- a/codecarbon/core/resource_tracker.py +++ b/codecarbon/core/resource_tracker.py @@ -1,7 +1,7 @@ from collections import Counter from typing import List, Union -from codecarbon.core import cpu, gpu, powermetrics +from codecarbon.core import cpu, gpu, macmon, powermetrics from codecarbon.core.config import parse_gpu_ids from codecarbon.core.util import detect_cpu_model, is_linux_os, is_mac_os, is_windows_os from codecarbon.external.hardware import CPU, GPU, RAM, AppleSiliconChip @@ -36,13 +36,14 @@ def set_CPU_tracking(self): self.tracker._hardware.append(hardware) self.tracker._conf["cpu_model"] = hardware.get_model() # change code to check if powermetrics needs to be installed or just sudo setup - elif ( - powermetrics.is_powermetrics_available() - and self.tracker._default_cpu_power is None - ): - logger.info("Tracking Apple CPU and GPU via PowerMetrics") - self.gpu_tracker = "PowerMetrics" - self.cpu_tracker = "PowerMetrics" + elif self.tracker._default_cpu_power is None: + if macmon.is_macmon_available(): + self.gpu_tracker = "MacMon" + self.cpu_tracker = "MacMon" + elif powermetrics.is_powermetrics_available(): + self.cpu_tracker = "PowerMetrics" + self.gpu_tracker = "PowerMetrics" + logger.info(f"Tracking Apple CPU and GPU using {self.cpu_tracker}") hardware_cpu = AppleSiliconChip.from_utils( self.tracker._output_dir, chip_part="CPU" ) @@ -60,11 +61,7 @@ def set_CPU_tracking(self): # Explain what to install to increase accuracy cpu_tracking_install_instructions = "" if is_mac_os(): - if ( - "M1" in detect_cpu_model() - or "M2" in detect_cpu_model() - or "M3" in detect_cpu_model() - ): + if any((m in detect_cpu_model() for m in ["M1", "M2", "M3", "M4"])): cpu_tracking_install_instructions = "" cpu_tracking_install_instructions = "Mac OS and ARM processor detected: Please enable PowerMetrics sudo to measure CPU" else: From 29efa24de2fe3af8eb7059190aa36e6efa44c7b4 Mon Sep 17 00:00:00 2001 From: LuisBlanche Date: Sat, 21 Dec 2024 11:44:18 +0100 Subject: [PATCH 06/15] feat: :sparkles: support of macmon macmon priority over powermetrics --- codecarbon/external/hardware.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/codecarbon/external/hardware.py b/codecarbon/external/hardware.py index 846f859e4..eec6feaef 100644 --- a/codecarbon/external/hardware.py +++ b/codecarbon/external/hardware.py @@ -12,7 +12,8 @@ from codecarbon.core.cpu import IntelPowerGadget, IntelRAPL from codecarbon.core.gpu import AllGPUDevices -from codecarbon.core.powermetrics import ApplePowermetrics +from codecarbon.core.macmon import MacMon, is_macmon_available +from codecarbon.core.powermetrics import ApplePowermetrics, is_powermetrics_available from codecarbon.core.units import Energy, Power, Time from codecarbon.core.util import SLURM_JOB_ID, detect_cpu_model from codecarbon.external.logger import logger @@ -427,7 +428,12 @@ def __init__( ): self._output_dir = output_dir self._model = model - self._interface = ApplePowermetrics(self._output_dir) + if is_macmon_available(): + self._interface = MacMon(self._output_dir) + elif is_powermetrics_available(): + self._interface = ApplePowermetrics(self._output_dir) + else: + raise Exception("No supported interface found for Apple Silicon Chip.") self.chip_part = chip_part def __repr__(self) -> str: From 66ee9bb163b835a5b2e957d183a4cf6678c36ff1 Mon Sep 17 00:00:00 2001 From: LuisBlanche Date: Sat, 21 Dec 2024 12:22:08 +0100 Subject: [PATCH 07/15] fix: :bug: split powermetrcis and macmon --- codecarbon/core/resource_tracker.py | 31 +++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/codecarbon/core/resource_tracker.py b/codecarbon/core/resource_tracker.py index 33c4f64fb..1dfc7263a 100644 --- a/codecarbon/core/resource_tracker.py +++ b/codecarbon/core/resource_tracker.py @@ -35,14 +35,29 @@ def set_CPU_tracking(self): hardware = CPU.from_utils(self.tracker._output_dir, "intel_rapl") self.tracker._hardware.append(hardware) self.tracker._conf["cpu_model"] = hardware.get_model() - # change code to check if powermetrics needs to be installed or just sudo setup - elif self.tracker._default_cpu_power is None: - if macmon.is_macmon_available(): - self.gpu_tracker = "MacMon" - self.cpu_tracker = "MacMon" - elif powermetrics.is_powermetrics_available(): - self.cpu_tracker = "PowerMetrics" - self.gpu_tracker = "PowerMetrics" + elif self.tracker._default_cpu_power is None and macmon.is_macmon_available(): + self.gpu_tracker = "MacMon" + self.cpu_tracker = "MacMon" + logger.info(f"Tracking Apple CPU and GPU using {self.cpu_tracker}") + hardware_cpu = AppleSiliconChip.from_utils( + self.tracker._output_dir, chip_part="CPU" + ) + self.tracker._hardware.append(hardware_cpu) + self.tracker._conf["cpu_model"] = hardware_cpu.get_model() + + hardware_gpu = AppleSiliconChip.from_utils( + self.tracker._output_dir, chip_part="GPU" + ) + self.tracker._hardware.append(hardware_gpu) + + self.tracker._conf["gpu_model"] = hardware_gpu.get_model() + self.tracker._conf["gpu_count"] = 1 + elif ( + self.tracker._default_cpu_power is None + and powermetrics.is_powermetrics_available() + ): + self.gpu_tracker = "PowerMetrics" + self.cpu_tracker = "PowerMetrics" logger.info(f"Tracking Apple CPU and GPU using {self.cpu_tracker}") hardware_cpu = AppleSiliconChip.from_utils( self.tracker._output_dir, chip_part="CPU" From e8b44eaf042d2501a72257e38f78a4c165e2d959 Mon Sep 17 00:00:00 2001 From: LuisBlanche Date: Fri, 3 Jan 2025 12:09:38 +0100 Subject: [PATCH 08/15] fix: :art: fix log after review add macmon and remove useless line --- codecarbon/core/resource_tracker.py | 49 +++++++++-------------------- 1 file changed, 14 insertions(+), 35 deletions(-) diff --git a/codecarbon/core/resource_tracker.py b/codecarbon/core/resource_tracker.py index 1dfc7263a..b7bd1f391 100644 --- a/codecarbon/core/resource_tracker.py +++ b/codecarbon/core/resource_tracker.py @@ -39,35 +39,24 @@ def set_CPU_tracking(self): self.gpu_tracker = "MacMon" self.cpu_tracker = "MacMon" logger.info(f"Tracking Apple CPU and GPU using {self.cpu_tracker}") - hardware_cpu = AppleSiliconChip.from_utils( - self.tracker._output_dir, chip_part="CPU" - ) + hardware_cpu = AppleSiliconChip.from_utils(self.tracker._output_dir, chip_part="CPU") self.tracker._hardware.append(hardware_cpu) self.tracker._conf["cpu_model"] = hardware_cpu.get_model() - hardware_gpu = AppleSiliconChip.from_utils( - self.tracker._output_dir, chip_part="GPU" - ) + hardware_gpu = AppleSiliconChip.from_utils(self.tracker._output_dir, chip_part="GPU") self.tracker._hardware.append(hardware_gpu) self.tracker._conf["gpu_model"] = hardware_gpu.get_model() self.tracker._conf["gpu_count"] = 1 - elif ( - self.tracker._default_cpu_power is None - and powermetrics.is_powermetrics_available() - ): + elif self.tracker._default_cpu_power is None and powermetrics.is_powermetrics_available(): self.gpu_tracker = "PowerMetrics" self.cpu_tracker = "PowerMetrics" logger.info(f"Tracking Apple CPU and GPU using {self.cpu_tracker}") - hardware_cpu = AppleSiliconChip.from_utils( - self.tracker._output_dir, chip_part="CPU" - ) + hardware_cpu = AppleSiliconChip.from_utils(self.tracker._output_dir, chip_part="CPU") self.tracker._hardware.append(hardware_cpu) self.tracker._conf["cpu_model"] = hardware_cpu.get_model() - hardware_gpu = AppleSiliconChip.from_utils( - self.tracker._output_dir, chip_part="GPU" - ) + hardware_gpu = AppleSiliconChip.from_utils(self.tracker._output_dir, chip_part="GPU") self.tracker._hardware.append(hardware_gpu) self.tracker._conf["gpu_model"] = hardware_gpu.get_model() @@ -77,12 +66,13 @@ def set_CPU_tracking(self): cpu_tracking_install_instructions = "" if is_mac_os(): if any((m in detect_cpu_model() for m in ["M1", "M2", "M3", "M4"])): - cpu_tracking_install_instructions = "" - cpu_tracking_install_instructions = "Mac OS and ARM processor detected: Please enable PowerMetrics sudo to measure CPU" + cpu_tracking_install_instructions = "Mac OS and ARM processor detected: Please enable PowerMetrics with sudo or MacMon to measure CPU" else: cpu_tracking_install_instructions = "Mac OS detected: Please install Intel Power Gadget or enable PowerMetrics sudo to measure CPU" elif is_windows_os(): - cpu_tracking_install_instructions = "Windows OS detected: Please install Intel Power Gadget to measure CPU" + cpu_tracking_install_instructions = ( + "Windows OS detected: Please install Intel Power Gadget to measure CPU" + ) elif is_linux_os(): cpu_tracking_install_instructions = "Linux OS detected: Please ensure RAPL files exist at \\sys\\class\\powercap\\intel-rapl to measure CPU" logger.warning( @@ -101,15 +91,10 @@ def set_CPU_tracking(self): logger.info(f"CPU Model on constant consumption mode: {model}") self.tracker._conf["cpu_model"] = model if tdp: - hardware = CPU.from_utils( - self.tracker._output_dir, "constant", model, power - ) + hardware = CPU.from_utils(self.tracker._output_dir, "constant", model, power) self.tracker._hardware.append(hardware) else: - logger.warning( - "Failed to match CPU TDP constant. " - + "Falling back on a global constant." - ) + logger.warning("Failed to match CPU TDP constant. " + "Falling back on a global constant.") self.cpu_tracker = "global constant" hardware = CPU.from_utils(self.tracker._output_dir, "constant") self.tracker._hardware.append(hardware) @@ -126,22 +111,16 @@ def set_GPU_tracking(self): self.tracker._conf["gpu_ids"] = self.tracker._gpu_ids self.tracker._conf["gpu_count"] = len(self.tracker._gpu_ids) else: - logger.warning( - "Invalid gpu_ids format. Expected a string or a list of ints." - ) + logger.warning("Invalid gpu_ids format. Expected a string or a list of ints.") if gpu.is_gpu_details_available(): logger.info("Tracking Nvidia GPU via pynvml") gpu_devices = GPU.from_utils(self.tracker._gpu_ids) self.tracker._hardware.append(gpu_devices) gpu_names = [n["name"] for n in gpu_devices.devices.get_gpu_static_info()] gpu_names_dict = Counter(gpu_names) - self.tracker._conf["gpu_model"] = "".join( - [f"{i} x {name}" for name, i in gpu_names_dict.items()] - ) + self.tracker._conf["gpu_model"] = "".join([f"{i} x {name}" for name, i in gpu_names_dict.items()]) if self.tracker._conf.get("gpu_count") is None: - self.tracker._conf["gpu_count"] = len( - gpu_devices.devices.get_gpu_static_info() - ) + self.tracker._conf["gpu_count"] = len(gpu_devices.devices.get_gpu_static_info()) else: logger.info("No GPU found.") From dc577fbd0ecb665fa3e4ab89da8ff768d796fa05 Mon Sep 17 00:00:00 2001 From: LuisBlanche Date: Fri, 3 Jan 2025 17:51:58 +0100 Subject: [PATCH 09/15] fix: :art: black formatting --- codecarbon/core/resource_tracker.py | 46 +++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/codecarbon/core/resource_tracker.py b/codecarbon/core/resource_tracker.py index b7bd1f391..b73ed48c8 100644 --- a/codecarbon/core/resource_tracker.py +++ b/codecarbon/core/resource_tracker.py @@ -39,24 +39,35 @@ def set_CPU_tracking(self): self.gpu_tracker = "MacMon" self.cpu_tracker = "MacMon" logger.info(f"Tracking Apple CPU and GPU using {self.cpu_tracker}") - hardware_cpu = AppleSiliconChip.from_utils(self.tracker._output_dir, chip_part="CPU") + hardware_cpu = AppleSiliconChip.from_utils( + self.tracker._output_dir, chip_part="CPU" + ) self.tracker._hardware.append(hardware_cpu) self.tracker._conf["cpu_model"] = hardware_cpu.get_model() - hardware_gpu = AppleSiliconChip.from_utils(self.tracker._output_dir, chip_part="GPU") + hardware_gpu = AppleSiliconChip.from_utils( + self.tracker._output_dir, chip_part="GPU" + ) self.tracker._hardware.append(hardware_gpu) self.tracker._conf["gpu_model"] = hardware_gpu.get_model() self.tracker._conf["gpu_count"] = 1 - elif self.tracker._default_cpu_power is None and powermetrics.is_powermetrics_available(): + elif ( + self.tracker._default_cpu_power is None + and powermetrics.is_powermetrics_available() + ): self.gpu_tracker = "PowerMetrics" self.cpu_tracker = "PowerMetrics" logger.info(f"Tracking Apple CPU and GPU using {self.cpu_tracker}") - hardware_cpu = AppleSiliconChip.from_utils(self.tracker._output_dir, chip_part="CPU") + hardware_cpu = AppleSiliconChip.from_utils( + self.tracker._output_dir, chip_part="CPU" + ) self.tracker._hardware.append(hardware_cpu) self.tracker._conf["cpu_model"] = hardware_cpu.get_model() - hardware_gpu = AppleSiliconChip.from_utils(self.tracker._output_dir, chip_part="GPU") + hardware_gpu = AppleSiliconChip.from_utils( + self.tracker._output_dir, chip_part="GPU" + ) self.tracker._hardware.append(hardware_gpu) self.tracker._conf["gpu_model"] = hardware_gpu.get_model() @@ -70,9 +81,7 @@ def set_CPU_tracking(self): else: cpu_tracking_install_instructions = "Mac OS detected: Please install Intel Power Gadget or enable PowerMetrics sudo to measure CPU" elif is_windows_os(): - cpu_tracking_install_instructions = ( - "Windows OS detected: Please install Intel Power Gadget to measure CPU" - ) + cpu_tracking_install_instructions = "Windows OS detected: Please install Intel Power Gadget to measure CPU" elif is_linux_os(): cpu_tracking_install_instructions = "Linux OS detected: Please ensure RAPL files exist at \\sys\\class\\powercap\\intel-rapl to measure CPU" logger.warning( @@ -91,10 +100,15 @@ def set_CPU_tracking(self): logger.info(f"CPU Model on constant consumption mode: {model}") self.tracker._conf["cpu_model"] = model if tdp: - hardware = CPU.from_utils(self.tracker._output_dir, "constant", model, power) + hardware = CPU.from_utils( + self.tracker._output_dir, "constant", model, power + ) self.tracker._hardware.append(hardware) else: - logger.warning("Failed to match CPU TDP constant. " + "Falling back on a global constant.") + logger.warning( + "Failed to match CPU TDP constant. " + + "Falling back on a global constant." + ) self.cpu_tracker = "global constant" hardware = CPU.from_utils(self.tracker._output_dir, "constant") self.tracker._hardware.append(hardware) @@ -111,16 +125,22 @@ def set_GPU_tracking(self): self.tracker._conf["gpu_ids"] = self.tracker._gpu_ids self.tracker._conf["gpu_count"] = len(self.tracker._gpu_ids) else: - logger.warning("Invalid gpu_ids format. Expected a string or a list of ints.") + logger.warning( + "Invalid gpu_ids format. Expected a string or a list of ints." + ) if gpu.is_gpu_details_available(): logger.info("Tracking Nvidia GPU via pynvml") gpu_devices = GPU.from_utils(self.tracker._gpu_ids) self.tracker._hardware.append(gpu_devices) gpu_names = [n["name"] for n in gpu_devices.devices.get_gpu_static_info()] gpu_names_dict = Counter(gpu_names) - self.tracker._conf["gpu_model"] = "".join([f"{i} x {name}" for name, i in gpu_names_dict.items()]) + self.tracker._conf["gpu_model"] = "".join( + [f"{i} x {name}" for name, i in gpu_names_dict.items()] + ) if self.tracker._conf.get("gpu_count") is None: - self.tracker._conf["gpu_count"] = len(gpu_devices.devices.get_gpu_static_info()) + self.tracker._conf["gpu_count"] = len( + gpu_devices.devices.get_gpu_static_info() + ) else: logger.info("No GPU found.") From 59c715780eff2f5de7b71db832e8f47f0ab9390c Mon Sep 17 00:00:00 2001 From: LuisBlanche Date: Fri, 17 Jan 2025 17:03:08 +0100 Subject: [PATCH 10/15] docs: :memo: update doc regarding mac Silicon chips --- docs/_sources/methodology.rst.txt | 23 +++++++++-- docs/_static/pygments.css | 66 +++++++++++++++--------------- docs/api.html | 10 ++--- docs/comet.html | 2 +- docs/edit/methodology.rst | 23 +++++++++-- docs/examples.html | 16 ++++---- docs/faq.html | 2 +- docs/genindex.html | 2 +- docs/index.html | 2 +- docs/installation.html | 2 +- docs/methodology.html | 26 +++++++++--- docs/model_examples.html | 2 +- docs/motivation.html | 2 +- docs/objects.inv | Bin 818 -> 575 bytes docs/output.html | 2 +- docs/parameters.html | 2 +- docs/search.html | 2 +- docs/searchindex.js | 2 +- docs/to_logger.html | 6 +-- docs/usage.html | 20 ++++----- docs/visualize.html | 2 +- 21 files changed, 129 insertions(+), 85 deletions(-) diff --git a/docs/_sources/methodology.rst.txt b/docs/_sources/methodology.rst.txt index 061b0d696..4e297da66 100644 --- a/docs/_sources/methodology.rst.txt +++ b/docs/_sources/methodology.rst.txt @@ -94,14 +94,29 @@ CPU - **On Windows or Mac (Intel)** Tracks Intel processors energy consumption using the ``Intel Power Gadget``. You need to install it yourself from this `source `_ . +WARNING : The Intel Power Gadget is not available on Apple Silicon Macs. +WARNING 2 : Intel Power Gadget has been deprecated by Intel, and it is not available for the latest processors. We are looking for alternatives. -- **Apple Silicon Chips (M1, M2)** +- **Apple Silicon Chips (M1, M2, M3, M4)** Apple Silicon Chips contain both the CPU and the GPU. -Codecarbon tracks Apple Silicon Chip energy consumption using ``powermetrics``. It should be available natively on any mac. -However, this tool is only usable with ``sudo`` rights and to our current knowledge, there are no other options to track the energy consumption of the Apple Silicon Chip without administrative rights -(if you know of any solution for this do not hesitate and `open an issue with your proposed solution `_). +There are two options to track the energy consumption of the Apple Silicon Chip: + - `Powermetrics `_ The mac native utility to monitor energy consumption on Apple Silicon Macs. + - `macmon `_ : a utility that allows you to monitor the energy consumption of your Apple Silicon Mac, it has the advantage of not requiring sudo privileges. + +In order to provide the easiest for the user, codecarbon uses macmon if it is available, otherwise it falls back to powermetrics, and if none of them are available, it falls back to constant mode using TDP. +Powermetrics should be available natively on any mac, but macmon requires installation. + +To use the ``macmon`` utility, you can use the following command: + +.. code-block:: bash + + brew install macmon + +And ``codecarbon`` will automatically detect and use it. + +If you prefer to use ``powermetrics`` with ``codecarbon`` then you need to give it ``sudo`` rights. To give sudo rights without having to enter a password each time, you can modify the sudoers file with the following command: diff --git a/docs/_static/pygments.css b/docs/_static/pygments.css index 0d49244ed..5f2b0a250 100644 --- a/docs/_static/pygments.css +++ b/docs/_static/pygments.css @@ -6,26 +6,26 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: .highlight .hll { background-color: #ffffcc } .highlight { background: #eeffcc; } .highlight .c { color: #408090; font-style: italic } /* Comment */ -.highlight .err { border: 1px solid #FF0000 } /* Error */ +.highlight .err { border: 1px solid #F00 } /* Error */ .highlight .k { color: #007020; font-weight: bold } /* Keyword */ -.highlight .o { color: #666666 } /* Operator */ +.highlight .o { color: #666 } /* Operator */ .highlight .ch { color: #408090; font-style: italic } /* Comment.Hashbang */ .highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */ .highlight .cp { color: #007020 } /* Comment.Preproc */ .highlight .cpf { color: #408090; font-style: italic } /* Comment.PreprocFile */ .highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */ -.highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */ +.highlight .cs { color: #408090; background-color: #FFF0F0 } /* Comment.Special */ .highlight .gd { color: #A00000 } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ -.highlight .gr { color: #FF0000 } /* Generic.Error */ +.highlight .gr { color: #F00 } /* Generic.Error */ .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ .highlight .gi { color: #00A000 } /* Generic.Inserted */ -.highlight .go { color: #333333 } /* Generic.Output */ -.highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */ +.highlight .go { color: #333 } /* Generic.Output */ +.highlight .gp { color: #C65D09; font-weight: bold } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ -.highlight .gt { color: #0044DD } /* Generic.Traceback */ +.highlight .gt { color: #04D } /* Generic.Traceback */ .highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */ @@ -33,43 +33,43 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: .highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #902000 } /* Keyword.Type */ .highlight .m { color: #208050 } /* Literal.Number */ -.highlight .s { color: #4070a0 } /* Literal.String */ -.highlight .na { color: #4070a0 } /* Name.Attribute */ +.highlight .s { color: #4070A0 } /* Literal.String */ +.highlight .na { color: #4070A0 } /* Name.Attribute */ .highlight .nb { color: #007020 } /* Name.Builtin */ -.highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */ -.highlight .no { color: #60add5 } /* Name.Constant */ -.highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */ -.highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */ +.highlight .nc { color: #0E84B5; font-weight: bold } /* Name.Class */ +.highlight .no { color: #60ADD5 } /* Name.Constant */ +.highlight .nd { color: #555; font-weight: bold } /* Name.Decorator */ +.highlight .ni { color: #D55537; font-weight: bold } /* Name.Entity */ .highlight .ne { color: #007020 } /* Name.Exception */ -.highlight .nf { color: #06287e } /* Name.Function */ +.highlight .nf { color: #06287E } /* Name.Function */ .highlight .nl { color: #002070; font-weight: bold } /* Name.Label */ -.highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */ +.highlight .nn { color: #0E84B5; font-weight: bold } /* Name.Namespace */ .highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */ -.highlight .nv { color: #bb60d5 } /* Name.Variable */ +.highlight .nv { color: #BB60D5 } /* Name.Variable */ .highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */ -.highlight .w { color: #bbbbbb } /* Text.Whitespace */ +.highlight .w { color: #BBB } /* Text.Whitespace */ .highlight .mb { color: #208050 } /* Literal.Number.Bin */ .highlight .mf { color: #208050 } /* Literal.Number.Float */ .highlight .mh { color: #208050 } /* Literal.Number.Hex */ .highlight .mi { color: #208050 } /* Literal.Number.Integer */ .highlight .mo { color: #208050 } /* Literal.Number.Oct */ -.highlight .sa { color: #4070a0 } /* Literal.String.Affix */ -.highlight .sb { color: #4070a0 } /* Literal.String.Backtick */ -.highlight .sc { color: #4070a0 } /* Literal.String.Char */ -.highlight .dl { color: #4070a0 } /* Literal.String.Delimiter */ -.highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */ -.highlight .s2 { color: #4070a0 } /* Literal.String.Double */ -.highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */ -.highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */ -.highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */ -.highlight .sx { color: #c65d09 } /* Literal.String.Other */ +.highlight .sa { color: #4070A0 } /* Literal.String.Affix */ +.highlight .sb { color: #4070A0 } /* Literal.String.Backtick */ +.highlight .sc { color: #4070A0 } /* Literal.String.Char */ +.highlight .dl { color: #4070A0 } /* Literal.String.Delimiter */ +.highlight .sd { color: #4070A0; font-style: italic } /* Literal.String.Doc */ +.highlight .s2 { color: #4070A0 } /* Literal.String.Double */ +.highlight .se { color: #4070A0; font-weight: bold } /* Literal.String.Escape */ +.highlight .sh { color: #4070A0 } /* Literal.String.Heredoc */ +.highlight .si { color: #70A0D0; font-style: italic } /* Literal.String.Interpol */ +.highlight .sx { color: #C65D09 } /* Literal.String.Other */ .highlight .sr { color: #235388 } /* Literal.String.Regex */ -.highlight .s1 { color: #4070a0 } /* Literal.String.Single */ +.highlight .s1 { color: #4070A0 } /* Literal.String.Single */ .highlight .ss { color: #517918 } /* Literal.String.Symbol */ .highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */ -.highlight .fm { color: #06287e } /* Name.Function.Magic */ -.highlight .vc { color: #bb60d5 } /* Name.Variable.Class */ -.highlight .vg { color: #bb60d5 } /* Name.Variable.Global */ -.highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */ -.highlight .vm { color: #bb60d5 } /* Name.Variable.Magic */ +.highlight .fm { color: #06287E } /* Name.Function.Magic */ +.highlight .vc { color: #BB60D5 } /* Name.Variable.Class */ +.highlight .vg { color: #BB60D5 } /* Name.Variable.Global */ +.highlight .vi { color: #BB60D5 } /* Name.Variable.Instance */ +.highlight .vm { color: #BB60D5 } /* Name.Variable.Magic */ .highlight .il { color: #208050 } /* Literal.Number.Integer.Long */ \ No newline at end of file diff --git a/docs/api.html b/docs/api.html index 2a20db5dd..0fd14fe5c 100644 --- a/docs/api.html +++ b/docs/api.html @@ -7,7 +7,7 @@ CodeCarbon API — CodeCarbon 2.8.2 documentation - + @@ -111,10 +111,10 @@

CodeCarbon API

Or use the API in your code:

-
from codecarbon import track_emissions
+
from codecarbon import track_emissions
 
 @track_emissions(save_to_api=True)
-def train_model():
+def train_model():
     # GPU intensive training code  goes here
 
 if __name__ =="__main__":
@@ -127,7 +127,7 @@ 

CodeCarbon APIAnd so on for your team, project and experiment.

You then have to set you experiment id in CodeCarbon, with two options:

In the code:

-
from codecarbon import track_emissions
+
diff --git a/docs/comet.html b/docs/comet.html
index d89b2fae0..504231d05 100644
--- a/docs/comet.html
+++ b/docs/comet.html
@@ -7,7 +7,7 @@
 
   
   Comet Integration — CodeCarbon 2.8.2 documentation
-      
+      
       
 
   
diff --git a/docs/edit/methodology.rst b/docs/edit/methodology.rst
index 061b0d696..4e297da66 100644
--- a/docs/edit/methodology.rst
+++ b/docs/edit/methodology.rst
@@ -94,14 +94,29 @@ CPU
 - **On Windows or Mac (Intel)**
 
 Tracks Intel processors energy consumption using the ``Intel Power Gadget``. You need to install it yourself from this `source `_ .
+WARNING : The Intel Power Gadget is not available on Apple Silicon Macs. 
+WARNING 2 : Intel Power Gadget has been deprecated by Intel, and it is not available for the latest processors. We are looking for alternatives.
 
-- **Apple Silicon Chips (M1, M2)**
+- **Apple Silicon Chips (M1, M2, M3, M4)**
 
 Apple Silicon Chips contain both the CPU and the GPU.
 
-Codecarbon tracks Apple Silicon Chip energy consumption using ``powermetrics``. It should be available natively on any mac.
-However, this tool is only usable with ``sudo`` rights and to our current knowledge, there are no other options to track the energy consumption of the Apple Silicon Chip without administrative rights
-(if you know of any solution for this do not hesitate and `open an issue with your proposed solution `_).
+There are two options to track the energy consumption of the Apple Silicon Chip:
+ - `Powermetrics `_ The mac native utility to monitor energy consumption on Apple Silicon Macs.
+ - `macmon `_ : a utility that allows you to monitor the energy consumption of your Apple Silicon Mac, it has the advantage of not requiring sudo privileges.
+
+In order to provide the easiest for the user, codecarbon uses macmon if it is available, otherwise it falls back to powermetrics, and if none of them are available, it falls back to constant mode using TDP.
+Powermetrics should be available natively on any mac, but macmon requires installation.
+
+To use the ``macmon`` utility, you can use the following command:
+
+.. code-block:: bash
+
+    brew install macmon
+
+And ``codecarbon`` will automatically detect and use it.
+
+If you prefer to use ``powermetrics`` with ``codecarbon`` then you need to give it ``sudo`` rights.
 
 To give sudo rights without having to enter a password each time, you can modify the sudoers file with the following command:
 
diff --git a/docs/examples.html b/docs/examples.html
index b6127806f..fd764add2 100644
--- a/docs/examples.html
+++ b/docs/examples.html
@@ -7,7 +7,7 @@
 
   
   Examples — CodeCarbon 2.8.2 documentation
-      
+      
       
 
   
@@ -100,9 +100,9 @@
 

Following are examples to train a Deep Learning model on MNIST Data to recognize digits in images using TensorFlow.

Using the Explicit Object

-
import tensorflow as tf
+
import tensorflow as tf
 
-from codecarbon import EmissionsTracker
+from codecarbon import EmissionsTracker
 
 mnist = tf.keras.datasets.mnist
 
@@ -133,9 +133,9 @@ 

Using the Explicit Object

Using the Context Manager

-
import tensorflow as tf
+
import tensorflow as tf
 
-from codecarbon import EmissionsTracker
+from codecarbon import EmissionsTracker
 
 mnist = tf.keras.datasets.mnist
 
@@ -162,13 +162,13 @@ 

Using the Context Manager

Using the Decorator

-
import tensorflow as tf
+
import tensorflow as tf
 
-from codecarbon import track_emissions
+from codecarbon import track_emissions
 
 
 @track_emissions(project_name="mnist")
-def train_model():
+def train_model():
     mnist = tf.keras.datasets.mnist
     (x_train, y_train), (x_test, y_test) = mnist.load_data()
     x_train, x_test = x_train / 255.0, x_test / 255.0
diff --git a/docs/faq.html b/docs/faq.html
index 388567191..582e99b48 100644
--- a/docs/faq.html
+++ b/docs/faq.html
@@ -7,7 +7,7 @@
 
   
   Frequently Asked Questions — CodeCarbon 2.8.2 documentation
-      
+      
       
 
   
diff --git a/docs/genindex.html b/docs/genindex.html
index 4bc300eff..fdcea8e6f 100644
--- a/docs/genindex.html
+++ b/docs/genindex.html
@@ -6,7 +6,7 @@
   
   
   Index — CodeCarbon 2.8.2 documentation
-      
+      
       
 
   
diff --git a/docs/index.html b/docs/index.html
index 98132fb66..dc457b7e6 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -7,7 +7,7 @@
 
   
   CodeCarbon — CodeCarbon 2.8.2 documentation
-      
+      
       
 
   
diff --git a/docs/installation.html b/docs/installation.html
index 05cbd412b..fb6fd7a9d 100644
--- a/docs/installation.html
+++ b/docs/installation.html
@@ -7,7 +7,7 @@
 
   
   Installing CodeCarbon — CodeCarbon 2.8.2 documentation
-      
+      
       
 
   
diff --git a/docs/methodology.html b/docs/methodology.html
index 4a0076603..05474a8b9 100644
--- a/docs/methodology.html
+++ b/docs/methodology.html
@@ -7,7 +7,7 @@
 
   
   Methodology — CodeCarbon 2.8.2 documentation
-      
+      
       
 
   
@@ -192,14 +192,28 @@ 

CPU
  • On Windows or Mac (Intel)

  • -

    Tracks Intel processors energy consumption using the Intel Power Gadget. You need to install it yourself from this source .

    +

    Tracks Intel processors energy consumption using the Intel Power Gadget. You need to install it yourself from this source . +WARNING : The Intel Power Gadget is not available on Apple Silicon Macs. +WARNING 2 : Intel Power Gadget has been deprecated by Intel, and it is not available for the latest processors. We are looking for alternatives.

      -
    • Apple Silicon Chips (M1, M2)

    • +
    • Apple Silicon Chips (M1, M2, M3, M4)

    Apple Silicon Chips contain both the CPU and the GPU.

    -

    Codecarbon tracks Apple Silicon Chip energy consumption using powermetrics. It should be available natively on any mac. -However, this tool is only usable with sudo rights and to our current knowledge, there are no other options to track the energy consumption of the Apple Silicon Chip without administrative rights -(if you know of any solution for this do not hesitate and open an issue with your proposed solution).

    +
    +
    There are two options to track the energy consumption of the Apple Silicon Chip:
      +
    • Powermetrics The mac native utility to monitor energy consumption on Apple Silicon Macs.

    • +
    • macmon : a utility that allows you to monitor the energy consumption of your Apple Silicon Mac, it has the advantage of not requiring sudo privileges.

    • +
    +
    +
    +

    In order to provide the easiest for the user, codecarbon uses macmon if it is available, otherwise it falls back to powermetrics, and if none of them are available, it falls back to constant mode using TDP. +Powermetrics should be available natively on any mac, but macmon requires installation.

    +

    To use the macmon utility, you can use the following command:

    +
    brew install macmon
    +
    +
    +

    And codecarbon will automatically detect and use it.

    +

    If you prefer to use powermetrics with codecarbon then you need to give it sudo rights.

    To give sudo rights without having to enter a password each time, you can modify the sudoers file with the following command:

    sudo visudo
     
    diff --git a/docs/model_examples.html b/docs/model_examples.html index 9eebf06c3..3b69ec852 100644 --- a/docs/model_examples.html +++ b/docs/model_examples.html @@ -7,7 +7,7 @@ Model Comparisons — CodeCarbon 2.8.2 documentation - + diff --git a/docs/motivation.html b/docs/motivation.html index 41b7cb774..ad5b060cd 100644 --- a/docs/motivation.html +++ b/docs/motivation.html @@ -7,7 +7,7 @@ Motivation — CodeCarbon 2.8.2 documentation - + diff --git a/docs/objects.inv b/docs/objects.inv index 0251f17b6909708d6646a7fc27d9e75d9d7fc4bb..3ca2bac60c0c1116f350fc8ee471a522c19e4577 100644 GIT binary patch delta 465 zcmV;?0WSWs2EPQ5cz=bI%Wi`(5JmTVg{5{&rEa^6qE^bHDp93wBL}9$iowK>DD>+) zVEh7R*7j+FX&C%juWt$e@+{3vRIn5_{`+p!E%Qv9oD~*D?)bMQA zYN#dEh-Pr3O~*mSfYU7VKAlpl?>{l)FueVjUgA(Z+Pn`57Xz*4J=v%;RAg^J4ZQ@! zhdT&!?_f2wtgYadvQD*Ccf-#t*ru)`N7y3Tl%|}I6H47dcd?@~Y~vp9n_48`&DJw; zQ72IeTxuV;5P!+GgU=u=7+-cyVbz4gviz|2Dx^=Qii0-1N*$F<4GUP|L+NG0)2QX% zzZ$r*(XP+k1K)|^FzvPxnq3zw3#vohc@9J!C&)0X012Zzll;A`V$;9I-?7Q3Mm9{G zjCf&+y8)RDJ*YOd@aH)YMw22~A%?=-9t^bT@ug_fxk@UavOJ}r)hzREpBJ=-%zw<{ z>!e?}#~(1GFe(lh1q<&DE6@0Mkvg*Zwt^7{5LvHG8OqsTlIlg9{Ns)@w+~PKSRfGp HJ}p7{#{B7x delta 710 zcmV;%0y+J^1hNK@cz?ZCU2obj6n*DcSn3|Oha_uP?O~cGRj8Ag+KsAJUn`T`f`?2V8&--hlboM2aDT&TWe5zSI(>W(!g?}WPX%628M>yWna$Xhp z^ckXyUQ#@4*dVtIADvLNeqH{r_V3d4R|QEqRq8FPXac->8M(|V{-)C~5&m7s z=gVG~Nq4($DSvicD5qI=OSRilImz*;wX!clKZ~W;2;G|B({kxI#D6Gd&w}YW##S-3 zV18UY8p=>+Fr?)~3UW0bSsJGk;6Cx}-6l1aoI|Ram=egDQcMa(v?P>pIh{fo`e^xN zVB_Y*krhW;Ml@QBhX>p-d=A<#sR7!e>bsH9FfFM@>3;y06q^OXd(>h^bG<%=RGWW5 z#%5UhGkx(*@o4lRxI$%pdS?Qt*J}-k9_g~GkPqMBa4IS4+ESTbKpbVPsP~$qb=S_iY zO(?+#zR30MKtspPrVab5fR^bj6dKHE?#=xeH$U>gE;GNJaKjy5V3k5E-=G1E_^x8< s96y&*do-JtBVq$Q>Vm0?a{LG4yIRmVKeopWwlxp=7{Dq10zKtYqRbXtb^rhX diff --git a/docs/output.html b/docs/output.html index 726147153..e9a0d33d8 100644 --- a/docs/output.html +++ b/docs/output.html @@ -7,7 +7,7 @@ Output — CodeCarbon 2.8.2 documentation - + diff --git a/docs/parameters.html b/docs/parameters.html index 2fd7a08d3..78f62eef9 100644 --- a/docs/parameters.html +++ b/docs/parameters.html @@ -7,7 +7,7 @@ Parameters — CodeCarbon 2.8.2 documentation - + diff --git a/docs/search.html b/docs/search.html index 8e021be6b..b43ee4364 100644 --- a/docs/search.html +++ b/docs/search.html @@ -6,7 +6,7 @@ Search — CodeCarbon 2.8.2 documentation - + diff --git a/docs/searchindex.js b/docs/searchindex.js index d369dac4f..f2e75af81 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({"alltitles": {"@track_emissions": [[22, "track-emissions"]], "Access internet through proxy server": [[24, "access-internet-through-proxy-server"]], "Authentication": [[23, "authentication"]], "CPU": [[18, "cpu"]], "CSV": [[21, "csv"]], "Carbon Intensity": [[18, "carbon-intensity"]], "Carbon Intensity Across Energy Sources": [[18, "id6"]], "Cloud Regions": [[25, "cloud-regions"]], "CodeCarbon": [[16, null]], "CodeCarbon API": [[12, null], [12, "id1"], [21, "codecarbon-api"]], "Collecting emissions to a logger": [[23, null]], "Comet Integration": [[13, null]], "Command line": [[24, "command-line"]], "Comparisons": [[19, "comparisons"]], "Configuration": [[24, "configuration"]], "Configuration priority": [[24, "configuration-priority"]], "Context manager": [[24, "context-manager"], [24, "id2"]], "Create a logger": [[23, "create-a-logger"]], "Create an EmissionTracker": [[23, "create-an-emissiontracker"]], "Data Fields Logged for Each Experiment": [[21, "id4"]], "Decorator": [[24, "decorator"], [24, "id3"]], "Dependencies": [[17, "dependencies"]], "Electricity consumption of AI cloud instance": [[19, "id1"]], "Electricity production carbon intensity per country": [[25, "electricity-production-carbon-intensity-per-country"]], "Example": [[23, "example"]], "Examples": [[14, null]], "Explicit Object": [[24, "explicit-object"], [24, "id1"]], "Frequently Asked Questions": [[15, null]], "From PyPi repository": [[17, "from-pypi-repository"]], "From conda repository": [[17, "from-conda-repository"]], "GPU": [[18, "gpu"]], "Getting Started": [[16, null]], "Google Cloud Logging": [[23, "google-cloud-logging"]], "HTTP Output": [[21, "http-output"]], "How CodeCarbon Works": [[18, "how-codecarbon-works"]], "How to test in local": [[21, "how-to-test-in-local"]], "How to use it": [[21, "how-to-use-it"]], "Impact of time of year and region": [[19, "impact-of-time-of-year-and-region"]], "Indices and tables": [[16, "indices-and-tables"]], "Input Parameters": [[22, "input-parameters"], [22, "id7"]], "Input Parameters to @track_emissions": [[22, "id10"]], "Input Parameters to OfflineEmissionsTracker": [[22, "id9"]], "Installing CodeCarbon": [[17, null]], "Introduction": [[16, null]], "Logfire": [[21, "logfire"]], "Logger Output": [[21, "logger-output"]], "Logging": [[16, null]], "Methodology": [[18, null]], "Model Comparisons": [[19, null]], "Motivation": [[20, null]], "Offline": [[25, "offline"]], "Offline Mode": [[24, "offline-mode"]], "Online (Beta)": [[25, "online-beta"]], "Online Mode": [[24, "online-mode"]], "Output": [[21, null]], "Output Parameters": [[22, "id8"]], "Output parameters": [[22, "output-parameters"]], "Parameters": [[22, null]], "Power Usage": [[18, "power-usage"]], "Prometheus": [[21, "prometheus"]], "Python logger": [[23, "python-logger"]], "Quickstart": [[24, null]], "RAM": [[18, "ram"]], "References": [[18, "references"], [19, "references"]], "Regional Comparisons": [[25, "regional-comparisons"]], "Specific parameters for offline mode": [[22, "specific-parameters-for-offline-mode"]], "Summary and Equivalents": [[25, "summary-and-equivalents"]], "The MIT License (MIT)": [[2, null], [8, null]], "Using CodeCarbon with logfire": [[21, "using-codecarbon-with-logfire"]], "Using CodeCarbon with prometheus": [[21, "using-codecarbon-with-prometheus"]], "Using the Context Manager": [[14, "using-the-context-manager"]], "Using the Decorator": [[14, "using-the-decorator"]], "Using the Explicit Object": [[14, "using-the-explicit-object"]], "Visualize": [[25, null]], "detailed": [[25, "detailed"]], "from global\u2026": [[25, "from-global"]], "to more and more\u2026": [[25, "to-more-and-more"]]}, "docnames": [".venv/lib/python3.10/site-packages/Jinja2-3.1.2.dist-info/LICENSE", ".venv/lib/python3.10/site-packages/MarkupSafe-2.1.2.dist-info/LICENSE", ".venv/lib/python3.10/site-packages/imagesize-1.4.1.dist-info/LICENSE", ".venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/base", ".venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/class", ".venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/module", ".venv/lib64/python3.10/site-packages/Jinja2-3.1.2.dist-info/LICENSE", ".venv/lib64/python3.10/site-packages/MarkupSafe-2.1.2.dist-info/LICENSE", ".venv/lib64/python3.10/site-packages/imagesize-1.4.1.dist-info/LICENSE", ".venv/lib64/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/base", ".venv/lib64/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/class", ".venv/lib64/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/module", "api", "comet", "examples", "faq", "index", "installation", "methodology", "model_examples", "motivation", "output", "parameters", "to_logger", "usage", "visualize"], "envversion": {"sphinx": 64, "sphinx.domains.c": 3, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 9, "sphinx.domains.index": 1, "sphinx.domains.javascript": 3, "sphinx.domains.math": 2, "sphinx.domains.python": 4, "sphinx.domains.rst": 2, "sphinx.domains.std": 2}, "filenames": [".venv/lib/python3.10/site-packages/Jinja2-3.1.2.dist-info/LICENSE.rst", ".venv/lib/python3.10/site-packages/MarkupSafe-2.1.2.dist-info/LICENSE.rst", ".venv/lib/python3.10/site-packages/imagesize-1.4.1.dist-info/LICENSE.rst", ".venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/base.rst", ".venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/class.rst", ".venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/module.rst", ".venv/lib64/python3.10/site-packages/Jinja2-3.1.2.dist-info/LICENSE.rst", ".venv/lib64/python3.10/site-packages/MarkupSafe-2.1.2.dist-info/LICENSE.rst", ".venv/lib64/python3.10/site-packages/imagesize-1.4.1.dist-info/LICENSE.rst", ".venv/lib64/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/base.rst", ".venv/lib64/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/class.rst", ".venv/lib64/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/module.rst", "api.rst", "comet.rst", "examples.rst", "faq.rst", "index.rst", "installation.rst", "methodology.rst", "model_examples.rst", "motivation.rst", "output.rst", "parameters.rst", "to_logger.rst", "usage.rst", "visualize.rst"], "indexentries": {}, "objects": {}, "objnames": {}, "objtypes": {}, "terms": {"": [13, 18, 20, 21, 22, 24, 25], "0": [14, 18, 19, 21, 24], "0000": 24, "02": 19, "03": 19, "04": 19, "1": [19, 21, 22, 24], "10": [14, 21, 24], "1065g7": 21, "1080": 21, "11": [19, 21], "121": 19, "123": 21, "128": 14, "13": 19, "14": 18, "15": [18, 22], "169": 19, "19": 19, "19044": 21, "192": 19, "2": [13, 14, 19, 21, 22], "2000": 18, "2007": [0, 6], "201": 19, "2010": [1, 7], "2016": [2, 8], "21": 19, "216": 19, "235b1da5": 24, "237": 19, "25": 18, "255": 14, "256": 19, "26": 18, "28": 14, "29": 18, "3": [13, 17, 18, 19, 21, 22, 24], "30": 12, "30ghz": 21, "32": 25, "3333": 25, "35": 18, "36": 19, "37": 19, "38": 18, "4": [12, 19, 24], "42": 22, "475": [15, 18], "48": 18, "5": 22, "50": 18, "59": 18, "6": 19, "6b": 19, "7": 19, "731": 18, "743": 18, "7777": 24, "8": [17, 18, 19, 21, 22], "8008": 24, "8050": 25, "812": 19, "816": 18, "893681599d2c": 24, "90": 19, "9090": 21, "93": 19, "995": 18, "A": [0, 1, 2, 6, 7, 8, 22, 23, 24, 25], "AND": [0, 1, 2, 6, 7, 8], "AS": [0, 1, 2, 6, 7, 8], "And": [12, 13], "As": [18, 20], "BE": [0, 1, 2, 6, 7, 8], "BUT": [0, 1, 2, 6, 7, 8], "BY": [0, 1, 6, 7], "But": [15, 18], "By": 21, "FOR": [0, 1, 2, 6, 7, 8], "For": [15, 17, 20, 21, 22, 24], "IF": [0, 1, 6, 7], "IN": [0, 1, 2, 6, 7, 8], "IT": 15, "If": [15, 18, 21, 22, 24, 25], "In": [12, 13, 18, 19, 20, 23, 24], "It": [12, 15, 18, 21, 23, 24], "NO": [0, 1, 2, 6, 7, 8], "NOT": [0, 1, 2, 6, 7, 8], "OF": [0, 1, 2, 6, 7, 8], "ON": [0, 1, 6, 7], "OR": [0, 1, 2, 6, 7, 8], "On": [18, 19], "One": 21, "Or": [12, 24], "SUCH": [0, 1, 6, 7], "THE": [0, 1, 2, 6, 7, 8], "TO": [0, 1, 2, 6, 7, 8], "The": [12, 17, 18, 19, 21, 22, 23, 24, 25], "Then": [12, 18], "There": 15, "To": [13, 17, 18], "WITH": [2, 8], "With": 20, "_": 24, "__main__": [12, 14], "__name__": [12, 14], "_channel": 23, "_logger": 23, "a100": 19, "aaaa": 24, "abl": [13, 21], "about": [15, 24], "abov": [0, 1, 2, 6, 7, 8, 17, 18], "absenc": 24, "access": 16, "account": [13, 18], "accur": [15, 18], "accuraci": 14, "achiev": 20, "across": [19, 20, 21, 25], "action": [2, 8], "activ": [14, 17, 25], "actual": 15, "adam": 14, "add": [13, 15, 18, 22, 23], "addhandl": 23, "addit": [22, 24], "administr": 18, "advanc": 20, "advis": [0, 1, 6, 7], "after": 23, "agenc": 19, "ai": 20, "alert": 21, "algorithm": 18, "all": [2, 8, 12, 15, 18, 21, 24, 25], "allow": [21, 22, 23, 24], "allow_multiple_run": 22, "along": [13, 17, 24], "alongsid": 13, "alphabet": [21, 24], "also": [20, 23, 24, 25], "although": 15, "amazon": 15, "amd": 18, "american": 25, "amount": [18, 20, 25], "an": [2, 8, 12, 13, 15, 18, 21, 24, 25], "analyz": 15, "ani": [0, 1, 2, 6, 7, 8, 15, 18, 24], "anoth": [19, 25], "anymor": 18, "api": [13, 16, 22, 24, 25], "api_call_interv": [12, 22, 24], "api_endpoint": 22, "api_kei": [13, 22], "app": 25, "appear": 21, "append": [18, 22], "appl": 18, "appli": 18, "approach": 20, "approxim": 18, "ar": [0, 1, 6, 7, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25], "argument": [22, 25], "aris": [0, 1, 2, 6, 7, 8], "arrow": 17, "art": 20, "artifact": [13, 22], "artifici": 20, "asia": 21, "ask": [16, 21], "associ": [2, 8, 18], "assum": 18, "attribut": 24, "auth": 21, "author": [2, 8], "automat": 13, "automaticli": 22, "avail": [14, 15, 18, 21, 22, 23, 24, 25], "averag": [15, 18, 19, 25], "aw": 21, "awar": [18, 24], "azur": [19, 21], "back": [13, 18], "bar": 25, "barchart": 25, "base": [18, 19, 21, 23, 24], "baseoutput": 21, "becaus": [15, 18, 24], "becom": 20, "befor": 12, "begin": 24, "being": [22, 25], "below": [19, 25], "benchmark": 25, "bert": 19, "bert_infer": 24, "best": 15, "beta": [16, 22], "better": 25, "between": [18, 22], "bin": 18, "binari": [0, 1, 6, 7], "biomass": 18, "black": 19, "block": [5, 11, 24], "blue": 19, "boolean": 22, "both": [18, 20, 24], "brazilsouth": 21, "broader": 20, "bubbl": 25, "build": [23, 24], "build_model": 24, "built": [21, 25], "busi": [0, 1, 6, 7], "c": [17, 18, 24], "calcul": [15, 18], "california": 22, "call": [18, 21, 22, 24], "can": [12, 13, 15, 18, 19, 20, 21, 23, 24, 25], "canada": 22, "car": 20, "carbon": [13, 15, 16, 19, 20, 24], "carbonboard": 25, "case": [15, 19, 21, 24, 25], "caus": [0, 1, 6, 7], "cell": 24, "center": 22, "central": [12, 23], "charg": [2, 8], "chart": 25, "chess": 20, "chip": 18, "choic": 15, "choos": [15, 22], "chose": 25, "citi": [21, 22], "claim": [2, 8], "class": [18, 21, 23], "cli": [17, 24, 25], "click": [13, 17, 25], "client": [17, 23], "cloud": [15, 18, 21, 22], "cloud_provid": [21, 22], "cloud_region": [21, 22], "co2": 24, "co2_signal_api_token": [22, 24], "co2sign": 22, "coal": 18, "code": [0, 1, 6, 7, 12, 13, 15, 21, 22, 24], "codecarbon": [13, 14, 15, 19, 22, 23, 24, 25], "codecarbon_": [21, 24], "codecarbon_gpu_id": 24, "codecarbon_log_level": 24, "collect": [16, 21], "collector": 23, "com": [15, 22], "combust": 20, "come": [24, 25], "comet": 16, "comet_ml": 13, "command": [17, 18, 25], "commun": 15, "compar": [13, 19, 25], "comparison": 16, "compil": 14, "complet": 24, "compos": [21, 24], "comput": [15, 18, 19, 20, 21, 24], "concern": 25, "conda": 16, "condit": [0, 1, 2, 6, 7, 8, 21], "config": [12, 24], "configpars": 24, "configur": [16, 18, 21], "connect": [2, 8, 23, 25], "consequ": 20, "consequenti": [0, 1, 6, 7], "consider": 19, "constant": 18, "consum": [18, 20, 25], "consumpt": [18, 22, 25], "consumption_percentage_const": 22, "contain": [18, 25], "context": 16, "contract": [0, 1, 2, 6, 7, 8], "contribut": 18, "contributor": [0, 1, 6, 7], "copi": [2, 8, 13], "copyright": [0, 1, 2, 6, 7, 8], "core": 21, "correspond": [18, 24], "could": [12, 18, 19, 22, 24], "count": 15, "countri": [15, 18, 21, 22, 24], "country_2letter_iso_cod": 22, "country_iso_cod": [21, 22, 24], "country_nam": 21, "cover": 15, "co\u2082": [18, 20, 21], "co\u2082eq": [18, 20, 21], "cpu": [21, 22], "cpu_count": 21, "cpu_energi": 21, "cpu_model": 21, "cpu_pow": 21, "cpuinfo": 17, "creat": [12, 13, 16, 17, 24], "critic": [22, 23], "csv": [16, 22, 24, 25], "ctrl": 24, "cuda_visible_devic": 22, "current": [18, 20, 21, 22, 24, 25], "curtail": 20, "custom": 21, "cycl": 15, "daili": 25, "damag": [0, 1, 2, 6, 7, 8], "dash": 25, "dashboard": 12, "data": [0, 1, 6, 7, 12, 13, 14, 15, 18, 20, 22, 23, 25], "databas": 21, "datacent": 15, "dataset": [13, 14, 24], "deal": [2, 8], "debug": [22, 23, 24], "decent": 18, "decor": [16, 22], "dedic": [22, 23], "deep": [14, 19], "def": [12, 14, 24], "default": [12, 13, 15, 18, 21, 22, 23, 24, 25], "default_cpu_pow": 22, "definit": 13, "demonstr": 23, "dens": [14, 19], "depend": [16, 20, 24], "deploi": [20, 21], "deriv": [0, 1, 6, 7, 21], "describ": 19, "descript": [21, 22], "design": 18, "detail": [13, 22, 24], "detect": 18, "develop": [19, 20, 21, 24], "devic": 21, "did": 15, "differ": [15, 18, 19, 20, 25], "digit": 14, "dioxid": [18, 20], "direct": [0, 1, 6, 7, 15], "directori": [18, 21, 22, 24], "disclaim": [0, 1, 6, 7], "disk": 24, "displai": [19, 21, 25], "distinct": 23, "distribut": [0, 1, 2, 6, 7, 8], "dive": 25, "divid": [21, 25], "do": [2, 8, 12, 15, 18, 24], "docker": [21, 24], "document": [0, 1, 2, 6, 7, 8, 23, 24], "doe": 15, "doesn": 18, "don": 18, "done": [15, 21], "drive": 20, "driven": 25, "dropout": 14, "dt": 21, "durat": 21, "dure": [18, 20], "e": [18, 21], "each": [18, 24, 25], "easier": 17, "easili": 13, "east": 21, "east1": 21, "eco": 25, "effect": 22, "effici": 20, "electr": [15, 18, 20, 22, 24], "els": 13, "emiss": [12, 13, 14, 15, 16, 18, 19, 20, 21, 22, 24, 25], "emissions_endpoint": 24, "emissions_r": 21, "emissionstrack": [13, 14, 23, 24], "emissiontrack": 21, "emit": [18, 19, 20], "empir": 18, "enabl": [20, 24], "encapsul": 22, "end": [18, 22], "endblock": [5, 11], "endfor": [5, 11], "endif": [5, 11], "endors": [0, 1, 6, 7], "endpoint": [22, 24], "energi": [15, 19, 20, 21, 25], "energy_consum": 21, "enhanc": [18, 21], "enorm": 20, "entail": 20, "enter": 18, "enterpris": 15, "entir": 22, "entireti": 15, "entri": 24, "environ": [13, 17, 21, 24], "environment": [18, 19, 20], "epoch": 14, "eq": [15, 18], "equival": [18, 19, 20, 21], "eras": 22, "error": 22, "escap": [3, 4, 5, 9, 10, 11], "estim": [15, 18, 19, 20, 22], "etc": 23, "evalu": 21, "even": [0, 1, 6, 7, 15], "event": [0, 1, 2, 6, 7, 8], "ever": [18, 25], "everi": [13, 18, 22], "everyth": [13, 24], "exampl": [13, 16, 18, 20, 21, 22, 24, 25], "execut": 25, "exemplari": [0, 1, 6, 7, 25], "exist": [15, 18, 22, 24, 25], "experi": [12, 13, 20, 22, 24, 25], "experiment_id": [12, 22, 24], "explain": 13, "explicit": 16, "explor": 25, "export": 24, "expos": 21, "express": [0, 1, 2, 6, 7, 8, 18, 20, 21], "face": 20, "fact": 20, "factor": [15, 18, 22], "fall": 18, "fallback": 18, "fals": [22, 24], "fast": 18, "featur": 20, "fetch": 24, "fief": 17, "file": [2, 8, 12, 13, 18, 21, 22, 23, 24, 25], "filehandl": 23, "filepath": 25, "filter": 23, "final": 24, "find": [15, 18], "fintetun": 19, "first": [18, 19, 21, 23, 24], "fit": [0, 1, 2, 6, 7, 8, 14], "flatten": 14, "float": [14, 23], "flush": [22, 24], "fn": 22, "focu": 15, "folder": 24, "follow": [0, 1, 2, 6, 7, 8, 14, 15, 17, 18, 19, 21, 22, 24, 25], "footprint": [13, 15, 18, 20], "forbid": 23, "forg": 17, "form": [0, 1, 6, 7], "format": 21, "former": 22, "fossil": [18, 20], "found": [13, 18, 24], "fourth": 19, "framework": 24, "free": [2, 8, 13, 22], "frequent": [16, 18], "friendli": 25, "from": [0, 1, 2, 6, 7, 8, 12, 13, 14, 15, 16, 18, 19, 21, 22, 23, 24], "from_logit": 14, "fuel": [18, 20], "fullnam": [3, 4, 5, 9, 10, 11], "function": [15, 22, 24], "furnish": [2, 8], "g": [18, 21], "ga": 18, "gadget": 18, "galleri": 13, "game": 20, "gase": 20, "gb": 18, "gco2": [15, 18], "gcp": 21, "geforc": 21, "gener": [18, 20, 24, 25], "geograph": 21, "geotherm": 18, "get": [12, 13, 22, 24, 25], "getlogg": 23, "github": 14, "give": 18, "given": 21, "global": [15, 18, 20, 22, 24], "global_energy_mix": 22, "globalpetrolpric": 15, "go": [13, 20, 21], "goe": [12, 24], "gold": 15, "good": [0, 1, 6, 7, 15, 18, 21], "googl": [15, 22], "google_project_nam": 23, "googlecloudloggeroutput": 23, "gpu": [12, 19, 21, 22, 24], "gpu_count": 21, "gpu_energi": 21, "gpu_id": [22, 24], "gpu_model": 21, "gpu_pow": 21, "grant": [2, 8], "graph": [13, 19], "great": 19, "greater": 15, "green": 22, "greenhous": 20, "grid": [18, 20, 25], "grow": 20, "gtx": 21, "h": [19, 21], "ha": [15, 18, 19, 20, 21, 24, 25], "habit": 15, "hand": 25, "handler": [22, 23], "happen": 25, "hard": 15, "hardwar": [18, 22], "have": [12, 13, 15, 18, 19, 20, 21, 22, 24], "header": 24, "help": [15, 18, 22], "here": [12, 15, 17, 18, 19, 23, 24], "herebi": [2, 8], "hesit": 18, "hi": 22, "hierarch": 24, "histor": 21, "holder": [0, 1, 2, 6, 7, 8], "home": 24, "hood": 24, "host": [17, 21, 22, 24, 25], "hour": [18, 19, 20], "household": 25, "how": [15, 24], "howev": [0, 1, 6, 7, 18, 24], "http": [16, 22, 24], "http_proxi": 24, "https_proxi": 24, "huge": 19, "human": 20, "hydroelectr": 18, "hyperparamet": 13, "i": [0, 1, 2, 6, 7, 8, 15, 17, 18, 20, 21, 22, 23, 24, 25], "i7": 21, "id": [12, 21, 22], "idea": 18, "iea": 15, "illustr": 25, "imag": [14, 20], "imdb": 24, "imdb_emiss": 24, "impact": [16, 20, 22], "implement": [21, 24], "impli": [0, 1, 2, 6, 7, 8], "import": [12, 14, 20, 23, 24], "improv": [15, 18], "inch": 25, "incident": [0, 1, 6, 7], "includ": [0, 1, 2, 6, 7, 8, 18, 22], "incred": 20, "index": 16, "indic": 22, "indirect": [0, 1, 6, 7], "industri": 20, "infer": 24, "info": [22, 23], "inform": [15, 24, 25], "infra": 15, "infrastructur": [15, 18, 21, 22, 24, 25], "ini": 24, "init": 12, "initi": [15, 24], "input": [16, 21], "input_shap": 14, "instal": [13, 16, 18], "instanc": [22, 24], "instanti": [18, 24], "instruct": 17, "integr": 16, "intel": [18, 21], "intellig": 20, "intens": [12, 15, 16, 19, 22, 24], "interfac": [12, 21], "interfer": 24, "intern": 24, "internet": 16, "interrupt": [0, 1, 6, 7], "interv": [18, 21, 22], "io": 22, "iso": [21, 22, 24], "isol": 22, "issu": [15, 18], "item": [5, 11], "its": [0, 1, 6, 7, 15, 18, 19, 21, 23, 25], "itself": [17, 18], "job": 13, "json": 22, "jupyt": 24, "just": 24, "keep": [15, 24], "kei": [13, 22], "kera": 14, "kg": [18, 21], "kgco\u2082": 18, "kilogram": [18, 20], "kilowatt": [18, 20], "kind": [2, 8], "km": 21, "km\u00b2": 21, "know": 18, "knowledg": 18, "known": [18, 22], "kwh": [15, 18, 19, 21], "lack": 23, "languag": 19, "larg": [19, 20], "last": [18, 24], "latest": 17, "latitud": 21, "layer": 14, "lcd": 25, "learn": [14, 19, 20], "left": [13, 25], "let": 15, "letter": [21, 22, 24], "level": [20, 22, 23, 25], "leverag": [20, 23], "liabil": [0, 1, 2, 6, 7, 8], "liabl": [0, 1, 2, 6, 7, 8], "librari": [18, 24], "life": [15, 25], "light": [18, 19], "like": [20, 24], "limit": [0, 1, 2, 6, 7, 8], "line": [18, 19], "link": 13, "linux": 18, "list": [0, 1, 6, 7, 17, 18, 22, 24], "ll": 13, "load": 24, "load_data": 14, "load_dataset": 24, "local": [15, 18, 23, 24], "localhost": [21, 24], "localis": 19, "locat": [19, 22], "log": [19, 22, 25], "log_level": [22, 24], "log_nam": 23, "logfir": [16, 22], "logger": [16, 22, 25], "logger_preambl": 22, "loggeroutput": [22, 23], "logging_demo": 23, "logging_logg": [22, 23], "longitud": 21, "loss": [0, 1, 6, 7, 14], "loss_fn": 14, "low": [18, 22], "m": 21, "m1": 18, "m2": 18, "mac": 18, "machin": [12, 20, 21, 22], "made": 15, "mai": [0, 1, 6, 7, 23], "main": 18, "major": 21, "make": [13, 15, 18], "manag": [16, 17], "mandatori": 22, "mani": 15, "manner": 24, "manual": [22, 24], "map": [18, 22], "materi": [0, 1, 6, 7], "matter": 20, "measur": [18, 19, 20, 22, 24], "measure_power_sec": [12, 18, 22, 24], "memori": 18, "mention": 18, "merchant": [0, 1, 2, 6, 7, 8], "merg": [2, 8], "messag": [22, 23], "met": [0, 1, 6, 7], "metadata": 25, "method": 18, "methodologi": 16, "metric": [13, 14, 21], "microsoft": [15, 19], "might": 19, "mile": 25, "mind": 15, "minim": 24, "miss": [15, 18], "mix": [15, 18, 25], "mixtur": 18, "ml": 13, "mnist": [13, 14], "mode": [12, 16, 18, 21], "model": [14, 16, 20, 24], "model_emiss": 24, "modif": [0, 1, 6, 7], "modifi": [2, 8, 18, 24], "modul": [5, 11, 16], "monitor": [12, 21, 24], "month": 20, "monthli": 15, "more": [12, 13, 18, 20, 24], "most": [19, 25], "motiv": 16, "much": 15, "multipl": 22, "multipli": 15, "must": [0, 1, 6, 7, 24], "mwh": 18, "my": 15, "my_logg": 23, "n": 21, "name": [0, 1, 6, 7, 17, 21, 22, 23, 24], "nativ": 18, "natur": 18, "nb": 19, "nearbi": 18, "need": [12, 13, 18, 21, 23, 24, 25], "neglig": [0, 1, 6, 7], "neither": [0, 1, 6, 7, 15, 18], "net": [18, 25], "network": 23, "new": 22, "nice": 12, "nlp": 19, "none": [18, 22], "noninfring": [2, 8], "nopasswd": 18, "nor": [0, 1, 6, 7, 18], "normal": 24, "notabl": 15, "note": [18, 24, 25], "notebook": 24, "noth": 21, "notic": [0, 1, 2, 6, 7, 8], "now": [13, 18, 25], "nuclear": 18, "number": [21, 22, 25], "nvidia": [18, 21], "o": [21, 24], "object": [13, 16, 20, 22], "observ": 21, "obtain": [2, 8], "offici": 17, "offlin": 16, "offlineemissionstrack": [21, 24], "offlineemissiontrack": 23, "offset": 15, "often": 15, "old": 22, "on_cloud": 21, "on_csv_writ": 22, "onc": [13, 21], "one": [12, 15, 21, 22, 23, 25], "onli": [15, 18, 22], "onlin": 16, "open": [15, 18], "openapi": 12, "optim": 14, "option": [12, 15, 18, 22, 23, 24, 25], "order": [20, 22, 23], "organ": 12, "organis": 25, "other": [0, 1, 2, 6, 7, 8, 14, 15, 18, 20, 23], "otherwis": [0, 1, 2, 6, 7, 8, 23], "our": [15, 18], "ourworld": 15, "out": [0, 1, 2, 6, 7, 8, 15], "output": [16, 23], "output_dir": [21, 22, 24], "output_fil": 22, "output_handl": 22, "overhead": [18, 24], "overrid": [22, 24], "overwrit": 24, "own": [12, 19], "p40": 19, "packag": [13, 15, 17, 18, 20, 21, 23, 25], "page": [13, 16], "pallet": [0, 1, 6, 7], "panda": 17, "panel": 13, "parallel": 23, "param": 24, "paramet": [16, 18, 21, 24], "part": [18, 20], "particular": [0, 1, 2, 6, 7, 8, 25], "pass": [18, 24], "password": 18, "path": [18, 22, 25], "pattern": 20, "per": [18, 20, 21, 22], "perform": 20, "permiss": [0, 1, 2, 6, 7, 8], "permit": [0, 1, 2, 6, 7, 8], "person": [2, 8, 13], "petroleum": 18, "piec": 24, "pip": [13, 17], "place": 21, "placehold": 13, "plai": [15, 20], "platform": [15, 21], "pleas": [15, 17, 18, 23, 24], "point": [19, 24, 25], "polici": 19, "popular": 19, "port": 25, "portion": [2, 8], "possibl": [0, 1, 6, 7, 18], "potenti": 20, "power": [13, 16, 20, 21, 22, 23, 25], "power_const": 22, "powercap": 18, "powermetr": 18, "precis": 21, "present": 19, "pretrain": 19, "prevent": 24, "preview": 25, "previou": 18, "price": 15, "print": 14, "prior": [0, 1, 6, 7], "prioriti": [15, 16], "privaci": 21, "privat": [15, 21, 23, 24], "process": [20, 21, 22, 23, 24, 25], "processor": [18, 20], "procur": [0, 1, 6, 7], "produc": [15, 20, 25], "product": [0, 1, 6, 7, 18], "profit": [0, 1, 6, 7], "program": 20, "project": [12, 14, 15, 21, 22, 23, 25], "project_nam": [14, 21, 22, 24], "prometheu": [16, 22], "prometheus_cli": 17, "prometheus_password": 21, "prometheus_url": 22, "prometheus_usernam": 21, "promot": [0, 1, 6, 7], "prompt": 24, "propos": 18, "protect": [19, 21], "provid": [0, 1, 2, 6, 7, 8, 13, 18, 21, 22, 23, 24, 25], "provinc": [21, 22], "proxi": 16, "psutil": 17, "public": [12, 13, 15, 24, 25], "publish": [2, 8, 15], "pue": 22, "purpos": [0, 1, 2, 6, 7, 8, 20], "push": 21, "pushgatewai": 21, "py": [13, 17, 21, 23], "pynvml": [17, 18], "pypi": 16, "pyproject": 17, "python": [17, 24], "python_vers": 21, "quantifi": [15, 18], "quartil": 19, "question": 16, "questionari": 17, "quickstart": 16, "r": 21, "ram": 21, "ram_energi": 21, "ram_pow": 21, "ram_total_s": 21, "rang": 21, "rapidfuzz": 17, "rapl": 18, "ratio": 18, "re": 24, "read": 24, "reason": 20, "recent": 20, "recogn": [14, 15, 20], "recommend": [15, 17, 24, 25], "record": 24, "recur": 15, "redistribut": [0, 1, 6, 7], "reduc": [15, 21], "refer": [16, 17, 23, 24], "region": [15, 16, 21, 22, 24], "relationship": 18, "releas": 15, "relev": 19, "reli": 24, "relu": 14, "remain": 24, "remark": 20, "render": 13, "renew": 18, "replac": 13, "repo": 15, "report": [18, 23], "repositori": [14, 16], "repres": 19, "reproduc": [0, 1, 6, 7, 13], "request": [17, 24], "requir": [21, 22, 24], "research": [13, 15], "resourc": 18, "respect": [21, 24], "restrict": [2, 8, 24], "result": [19, 21, 24], "retain": [0, 1, 6, 7], "return": [14, 24], "rich": 17, "right": [2, 8, 18, 19, 25], "room": 18, "root": 18, "row": 22, "rubric": [5, 11], "rule": 21, "run": [12, 13, 15, 17, 21, 22, 24, 25], "run_id": 22, "runtim": 25, "same": [22, 24], "sampl": 13, "satisfi": 18, "save": [12, 13, 22, 23, 24], "save_to_api": [12, 22, 24], "save_to_fil": [22, 24], "save_to_logfir": [21, 22], "save_to_logg": [22, 23], "save_to_prometheu": [21, 22], "scale": 19, "schedul": [18, 24], "scheme": 15, "scientist": 13, "script": 24, "sdk": 23, "search": [13, 16, 21], "second": [18, 21, 22], "section": 24, "sector": 20, "see": [13, 18, 21, 22, 23, 24, 25], "self": 21, "sell": [2, 8], "send": [21, 22, 23, 24], "sent": [21, 25], "sequenti": 14, "seri": 25, "server": [12, 16, 21, 22], "servic": [0, 1, 6, 7, 21], "set": [12, 13, 21, 22, 23, 24], "setlevel": 23, "sever": 25, "shall": [0, 1, 2, 6, 7, 8], "share": 25, "shell": 24, "shibukawa": [2, 8], "shot": 15, "should": [15, 18, 22], "show": [18, 19, 25], "shown": 25, "side": [19, 25], "sidebar": 13, "sign": 22, "signific": [18, 20], "silicon": 18, "singl": [15, 24], "small": [18, 19, 24], "so": [2, 8, 12, 15, 18, 21, 22, 24], "softwar": [0, 1, 2, 6, 7, 8], "solar": 18, "solut": 18, "some": [18, 23, 24], "soon": 24, "sophist": 20, "sourc": [0, 1, 6, 7, 15, 19], "sp0": 21, "sparsecategoricalcrossentropi": 14, "special": [0, 1, 6, 7], "specif": [0, 1, 6, 7, 16, 18, 20, 23, 24], "specifi": [12, 21, 22, 23], "split": 24, "standard": [15, 20, 22], "start": [13, 14, 18, 21, 23, 24], "start_task": 24, "state": [20, 21, 22], "statist": 18, "stdout": 13, "still": [18, 23], "stop": [14, 18, 21, 23, 24], "stop_task": 24, "stream": 23, "strict": [0, 1, 6, 7], "string": 22, "structur": 24, "studi": 19, "subclass": 23, "subject": [2, 8], "sublicens": [2, 8], "subscript": 15, "substanti": [2, 8], "substitut": [0, 1, 6, 7], "success": 15, "sudo": 18, "sudoer": 18, "suffix": 21, "sum": 21, "suppli": 18, "support": [18, 22, 23, 24], "sure": 13, "sustain": 15, "switch": [18, 25], "sy": 18, "syntax": 24, "system": [13, 21, 23], "systemat": 22, "t": [18, 24], "tab": 13, "tabl": [18, 19], "taken": 13, "target": 21, "task": [20, 24], "tdp": 18, "team": 12, "tell": 12, "tensorflow": 14, "termin": 17, "test": [18, 24], "tf": 14, "than": 23, "them": 15, "theori": [0, 1, 6, 7], "therefor": 15, "thermal": 18, "thi": [0, 1, 2, 6, 7, 8, 12, 15, 18, 19, 20, 21, 22, 23, 24, 25], "those": 25, "through": 16, "thu": 20, "ti": 21, "time": [13, 16, 18, 21, 24, 25], "timeseri": 12, "timestamp": 21, "tini": 19, "tm": 21, "token": [22, 24], "toml": 17, "tool": [13, 18, 19, 24], "toolkit": 18, "top": 25, "tort": [0, 1, 2, 6, 7, 8], "total": [21, 25], "track": [13, 18, 20, 21, 22, 23, 24], "track_emiss": [12, 14, 16, 24], "tracker": [14, 18, 21, 22, 23, 24], "tracking_mod": [21, 22, 24], "train": [12, 13, 14, 19, 20, 24], "train_model": [12, 14], "training_loop": 24, "transf": 19, "trigger": [21, 23], "true": [12, 14, 21, 22, 23, 24], "try": [15, 18, 22, 24], "tv": 25, "two": [12, 18, 24], "typer": 17, "typic": 23, "u": [18, 19, 21, 22], "ubiquit": 20, "ui": 13, "unchang": 24, "under": 24, "underli": [18, 20], "underlin": [3, 4, 5, 9, 10, 11], "understand": 25, "unfortun": 15, "up": [21, 22, 24], "updat": 22, "upload": 12, "url": 22, "us": [0, 1, 2, 6, 7, 8, 12, 15, 16, 17, 18, 19, 20, 22, 23, 24, 25], "usa": 21, "usabl": [18, 23], "usag": [16, 22], "user": [18, 22, 24, 25], "usernam": 18, "usr": 18, "usual": 21, "uuid": 24, "v100": 19, "valid": 23, "valu": [18, 21, 22, 24], "variabl": [22, 24], "variou": [20, 23, 25], "vast": 20, "ve": 13, "verbos": 22, "version": [21, 24], "via": [15, 20], "victor": 24, "view": [13, 15], "virtual": 17, "vision": 19, "visual": [13, 16], "visudo": 18, "vit": 19, "voil\u00e0": 13, "w": 21, "wai": [0, 1, 6, 7, 24], "want": [18, 22, 24], "warm": 20, "warn": [22, 24], "warranti": [0, 1, 2, 6, 7, 8], "watch": 25, "watt": [18, 22], "we": [15, 17, 18, 20, 24], "web": [12, 24], "webhook": 21, "websit": [13, 17], "week": 20, "weekli": 25, "weight": 18, "welcom": 18, "well": 15, "what": 15, "when": [13, 15, 18, 21, 22, 24], "where": [21, 22, 24], "whether": [0, 1, 2, 6, 7, 8], "which": [18, 20, 22, 24], "who": 25, "whom": [2, 8], "wikipedia": 24, "wind": 18, "window": [18, 21], "within": 24, "without": [0, 1, 2, 6, 7, 8, 18, 24], "wonder": 24, "work": [15, 20, 24], "world": [15, 18], "would": [19, 20], "wrap": 24, "wren": 15, "write": 24, "written": [0, 1, 6, 7, 22, 24], "x": [21, 22], "x_test": 14, "x_train": 14, "y": 21, "y_test": 14, "y_train": 14, "year": [16, 18, 20], "yet": 24, "yield": 24, "york": 22, "yoshiki": [2, 8], "you": [12, 13, 15, 18, 21, 22, 24, 25], "your": [12, 13, 15, 17, 18, 21, 22, 24, 25], "yourself": 18, "zone": 22}, "titles": ["<no title>", "<no title>", "The MIT License (MIT)", "<no title>", "<no title>", "<no title>", "<no title>", "<no title>", "The MIT License (MIT)", "<no title>", "<no title>", "<no title>", "CodeCarbon API", "Comet Integration", "Examples", "Frequently Asked Questions", "CodeCarbon", "Installing CodeCarbon", "Methodology", "Model Comparisons", "Motivation", "Output", "Parameters", "Collecting emissions to a logger", "Quickstart", "Visualize"], "titleterms": {"The": [2, 8], "access": 24, "across": 18, "ai": 19, "an": 23, "api": [12, 21], "ask": 15, "authent": 23, "beta": 25, "carbon": [18, 25], "cloud": [19, 23, 25], "codecarbon": [12, 16, 17, 18, 21], "collect": 23, "comet": 13, "command": 24, "comparison": [19, 25], "conda": 17, "configur": 24, "consumpt": 19, "context": [14, 24], "countri": 25, "cpu": 18, "creat": 23, "csv": 21, "data": 21, "decor": [14, 24], "depend": 17, "detail": 25, "each": 21, "electr": [19, 25], "emiss": 23, "emissiontrack": 23, "energi": 18, "equival": 25, "exampl": [14, 23], "experi": 21, "explicit": [14, 24], "field": 21, "frequent": 15, "from": [17, 25], "get": 16, "global": 25, "googl": 23, "gpu": 18, "how": [18, 21], "http": 21, "impact": 19, "indic": 16, "input": 22, "instal": 17, "instanc": 19, "integr": 13, "intens": [18, 25], "internet": 24, "introduct": 16, "licens": [2, 8], "line": 24, "local": 21, "log": [16, 21, 23], "logfir": 21, "logger": [21, 23], "manag": [14, 24], "methodologi": 18, "mit": [2, 8], "mode": [22, 24], "model": 19, "more": 25, "motiv": 20, "object": [14, 24], "offlin": [22, 24, 25], "offlineemissionstrack": 22, "onlin": [24, 25], "output": [21, 22], "paramet": 22, "per": 25, "power": 18, "prioriti": 24, "product": 25, "prometheu": 21, "proxi": 24, "pypi": 17, "python": 23, "question": 15, "quickstart": 24, "ram": 18, "refer": [18, 19], "region": [19, 25], "repositori": 17, "server": 24, "sourc": 18, "specif": 22, "start": 16, "summari": 25, "tabl": 16, "test": 21, "through": 24, "time": 19, "track_emiss": 22, "us": [14, 21], "usag": 18, "visual": 25, "work": 18, "year": 19}}) \ No newline at end of file +Search.setIndex({"alltitles": {"@track_emissions": [[10, "track-emissions"]], "Access internet through proxy server": [[12, "access-internet-through-proxy-server"]], "Authentication": [[11, "authentication"]], "CPU": [[6, "cpu"]], "CSV": [[9, "csv"]], "Carbon Intensity": [[6, "carbon-intensity"]], "Carbon Intensity Across Energy Sources": [[6, "id6"]], "Cloud Regions": [[13, "cloud-regions"]], "CodeCarbon": [[4, null]], "CodeCarbon API": [[0, null], [0, "id1"], [9, "codecarbon-api"]], "Collecting emissions to a logger": [[11, null]], "Comet Integration": [[1, null]], "Command line": [[12, "command-line"]], "Comparisons": [[7, "comparisons"]], "Configuration": [[12, "configuration"]], "Configuration priority": [[12, "configuration-priority"]], "Context manager": [[12, "context-manager"], [12, "id2"]], "Create a logger": [[11, "create-a-logger"]], "Create an EmissionTracker": [[11, "create-an-emissiontracker"]], "Data Fields Logged for Each Experiment": [[9, "id4"]], "Decorator": [[12, "decorator"], [12, "id3"]], "Dependencies": [[5, "dependencies"]], "Electricity consumption of AI cloud instance": [[7, "id1"]], "Electricity production carbon intensity per country": [[13, "electricity-production-carbon-intensity-per-country"]], "Example": [[11, "example"]], "Examples": [[2, null]], "Explicit Object": [[12, "explicit-object"], [12, "id1"]], "Frequently Asked Questions": [[3, null]], "From PyPi repository": [[5, "from-pypi-repository"]], "From conda repository": [[5, "from-conda-repository"]], "GPU": [[6, "gpu"]], "Getting Started": [[4, null]], "Google Cloud Logging": [[11, "google-cloud-logging"]], "HTTP Output": [[9, "http-output"]], "How CodeCarbon Works": [[6, "how-codecarbon-works"]], "How to test in local": [[9, "how-to-test-in-local"]], "How to use it": [[9, "how-to-use-it"]], "Impact of time of year and region": [[7, "impact-of-time-of-year-and-region"]], "Indices and tables": [[4, "indices-and-tables"]], "Input Parameters": [[10, "input-parameters"], [10, "id7"]], "Input Parameters to @track_emissions": [[10, "id10"]], "Input Parameters to OfflineEmissionsTracker": [[10, "id9"]], "Installing CodeCarbon": [[5, null]], "Introduction": [[4, null]], "Logfire": [[9, "logfire"]], "Logger Output": [[9, "logger-output"]], "Logging": [[4, null]], "Methodology": [[6, null]], "Model Comparisons": [[7, null]], "Motivation": [[8, null]], "Offline": [[13, "offline"]], "Offline Mode": [[12, "offline-mode"]], "Online (Beta)": [[13, "online-beta"]], "Online Mode": [[12, "online-mode"]], "Output": [[9, null]], "Output Parameters": [[10, "id8"]], "Output parameters": [[10, "output-parameters"]], "Parameters": [[10, null]], "Power Usage": [[6, "power-usage"]], "Prometheus": [[9, "prometheus"]], "Python logger": [[11, "python-logger"]], "Quickstart": [[12, null]], "RAM": [[6, "ram"]], "References": [[6, "references"], [7, "references"]], "Regional Comparisons": [[13, "regional-comparisons"]], "Specific parameters for offline mode": [[10, "specific-parameters-for-offline-mode"]], "Summary and Equivalents": [[13, "summary-and-equivalents"]], "Using CodeCarbon with logfire": [[9, "using-codecarbon-with-logfire"]], "Using CodeCarbon with prometheus": [[9, "using-codecarbon-with-prometheus"]], "Using the Context Manager": [[2, "using-the-context-manager"]], "Using the Decorator": [[2, "using-the-decorator"]], "Using the Explicit Object": [[2, "using-the-explicit-object"]], "Visualize": [[13, null]], "detailed": [[13, "detailed"]], "from global\u2026": [[13, "from-global"]], "to more and more\u2026": [[13, "to-more-and-more"]]}, "docnames": ["api", "comet", "examples", "faq", "index", "installation", "methodology", "model_examples", "motivation", "output", "parameters", "to_logger", "usage", "visualize"], "envversion": {"sphinx": 64, "sphinx.domains.c": 3, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 9, "sphinx.domains.index": 1, "sphinx.domains.javascript": 3, "sphinx.domains.math": 2, "sphinx.domains.python": 4, "sphinx.domains.rst": 2, "sphinx.domains.std": 2}, "filenames": ["api.rst", "comet.rst", "examples.rst", "faq.rst", "index.rst", "installation.rst", "methodology.rst", "model_examples.rst", "motivation.rst", "output.rst", "parameters.rst", "to_logger.rst", "usage.rst", "visualize.rst"], "indexentries": {}, "objects": {}, "objnames": {}, "objtypes": {}, "terms": {"": [1, 6, 8, 9, 10, 12, 13], "0": [2, 6, 7, 9, 12], "0000": 12, "02": 7, "03": 7, "04": 7, "1": [7, 9, 10, 12], "10": [2, 9, 12], "1065g7": 9, "1080": 9, "11": [7, 9], "121": 7, "123": 9, "128": 2, "13": 7, "14": 6, "15": [6, 10], "169": 7, "19": 7, "19044": 9, "192": 7, "2": [1, 2, 6, 7, 9, 10], "2000": 6, "201": 7, "21": 7, "216": 7, "235b1da5": 12, "237": 7, "25": 6, "255": 2, "256": 7, "26": 6, "28": 2, "29": 6, "3": [1, 5, 6, 7, 9, 10, 12], "30": 0, "30ghz": 9, "32": 13, "3333": 13, "35": 6, "36": 7, "37": 7, "38": 6, "4": [0, 7, 12], "42": 10, "475": [3, 6], "48": 6, "5": 10, "50": 6, "59": 6, "6": 7, "6b": 7, "7": 7, "731": 6, "743": 6, "7777": 12, "8": [5, 6, 7, 9, 10], "8008": 12, "8050": 13, "812": 7, "816": 6, "893681599d2c": 12, "90": 7, "9090": 9, "93": 7, "995": 6, "A": [10, 11, 12, 13], "And": [0, 1, 6], "As": [6, 8], "But": [3, 6], "By": 9, "For": [3, 5, 8, 9, 10, 12], "IT": 3, "If": [3, 6, 9, 10, 12, 13], "In": [0, 1, 6, 7, 8, 11, 12], "It": [0, 3, 6, 9, 11, 12], "On": [6, 7], "One": 9, "Or": [0, 12], "The": [0, 5, 6, 7, 9, 10, 11, 12, 13], "Then": [0, 6], "There": [3, 6], "To": [1, 5, 6], "With": 8, "_": 12, "__main__": [0, 2], "__name__": [0, 2], "_channel": 11, "_logger": 11, "a100": 7, "aaaa": 12, "abl": [1, 9], "about": [3, 12], "abov": [5, 6], "absenc": 12, "access": 4, "account": [1, 6], "accur": [3, 6], "accuraci": 2, "achiev": 8, "across": [7, 8, 9, 13], "activ": [2, 5, 13], "actual": 3, "adam": 2, "add": [1, 3, 6, 10, 11], "addhandl": 11, "addit": [10, 12], "advanc": 8, "advantag": 6, "after": 11, "agenc": 7, "ai": 8, "alert": 9, "algorithm": 6, "all": [0, 3, 6, 9, 12, 13], "allow": [6, 9, 10, 11, 12], "allow_multiple_run": 10, "along": [1, 5, 12], "alongsid": 1, "alphabet": [9, 12], "also": [8, 11, 12, 13], "altern": 6, "although": 3, "amazon": 3, "amd": 6, "american": 13, "amount": [6, 8, 13], "an": [0, 1, 3, 6, 9, 12, 13], "analyz": 3, "ani": [3, 6, 12], "anoth": [7, 13], "anymor": 6, "api": [1, 4, 10, 12, 13], "api_call_interv": [0, 10, 12], "api_endpoint": 10, "api_kei": [1, 10], "app": 13, "appear": 9, "append": [6, 10], "appl": 6, "appli": 6, "approach": 8, "approxim": 6, "ar": [2, 3, 5, 6, 7, 8, 9, 10, 11, 13], "argument": [10, 13], "arrow": 5, "art": 8, "artifact": [1, 10], "artifici": 8, "asia": 9, "ask": [4, 9], "associ": 6, "assum": 6, "attribut": 12, "auth": 9, "automat": [1, 6], "automaticli": 10, "avail": [2, 3, 6, 9, 10, 11, 12, 13], "averag": [3, 6, 7, 13], "aw": 9, "awar": [6, 12], "azur": [7, 9], "back": [1, 6], "bar": 13, "barchart": 13, "base": [6, 7, 9, 11, 12], "baseoutput": 9, "becaus": [3, 6, 12], "becom": 8, "been": 6, "befor": 0, "begin": 12, "being": [10, 13], "below": [7, 13], "benchmark": 13, "bert": 7, "bert_infer": 12, "best": 3, "beta": [4, 10], "better": 13, "between": [6, 10], "bin": 6, "biomass": 6, "black": 7, "block": 12, "blue": 7, "boolean": 10, "both": [6, 8, 12], "brazilsouth": 9, "brew": 6, "broader": 8, "bubbl": 13, "build": [11, 12], "build_model": 12, "built": [9, 13], "c": [5, 6, 12], "calcul": [3, 6], "california": 10, "call": [6, 9, 10, 12], "can": [0, 1, 3, 6, 7, 8, 9, 11, 12, 13], "canada": 10, "car": 8, "carbon": [1, 3, 4, 7, 8, 12], "carbonboard": 13, "case": [3, 7, 9, 12, 13], "cell": 12, "center": 10, "central": [0, 11], "chart": 13, "chess": 8, "chip": 6, "choic": 3, "choos": [3, 10], "chose": 13, "citi": [9, 10], "class": [6, 9, 11], "cli": [5, 12, 13], "click": [1, 5, 13], "client": [5, 11], "cloud": [3, 6, 9, 10], "cloud_provid": [9, 10], "cloud_region": [9, 10], "co2": 12, "co2_signal_api_token": [10, 12], "co2sign": 10, "coal": 6, "code": [0, 1, 3, 9, 10, 12], "codecarbon": [1, 2, 3, 7, 10, 11, 12, 13], "codecarbon_": [9, 12], "codecarbon_gpu_id": 12, "codecarbon_log_level": 12, "collect": [4, 9], "collector": 11, "com": [3, 10], "combust": 8, "come": [12, 13], "comet": 4, "comet_ml": 1, "command": [5, 6, 13], "commun": 3, "compar": [1, 7, 13], "comparison": 4, "compil": 2, "complet": 12, "compos": [9, 12], "comput": [3, 6, 7, 8, 9, 12], "concern": 13, "conda": 4, "condit": 9, "config": [0, 12], "configpars": 12, "configur": [4, 6, 9], "connect": [11, 13], "consequ": 8, "consider": 7, "constant": 6, "consum": [6, 8, 13], "consumpt": [6, 10, 13], "consumption_percentage_const": 10, "contain": [6, 13], "context": 4, "contribut": 6, "copi": 1, "core": 9, "correspond": [6, 12], "could": [0, 6, 7, 10, 12], "count": 3, "countri": [3, 6, 9, 10, 12], "country_2letter_iso_cod": 10, "country_iso_cod": [9, 10, 12], "country_nam": 9, "cover": 3, "co\u2082": [6, 8, 9], "co\u2082eq": [6, 8, 9], "cpu": [9, 10], "cpu_count": 9, "cpu_energi": 9, "cpu_model": 9, "cpu_pow": 9, "cpuinfo": 5, "creat": [0, 1, 4, 5, 12], "critic": [10, 11], "csv": [4, 10, 12, 13], "ctrl": 12, "cuda_visible_devic": 10, "current": [6, 8, 9, 10, 12, 13], "curtail": 8, "custom": 9, "cycl": 3, "daili": 13, "dash": 13, "dashboard": 0, "data": [0, 1, 2, 3, 6, 8, 10, 11, 13], "databas": 9, "datacent": 3, "dataset": [1, 2, 12], "debug": [10, 11, 12], "decent": 6, "decor": [4, 10], "dedic": [10, 11], "deep": [2, 7], "def": [0, 2, 12], "default": [0, 1, 3, 6, 9, 10, 11, 12, 13], "default_cpu_pow": 10, "definit": 1, "demonstr": 11, "dens": [2, 7], "depend": [4, 8, 12], "deploi": [8, 9], "deprec": 6, "deriv": 9, "describ": 7, "descript": [9, 10], "design": 6, "detail": [1, 10, 12], "detect": 6, "develop": [7, 8, 9, 12], "devic": 9, "did": 3, "differ": [3, 6, 7, 8, 13], "digit": 2, "dioxid": [6, 8], "direct": 3, "directori": [6, 9, 10, 12], "disk": 12, "displai": [7, 9, 13], "distinct": 11, "dive": 13, "divid": [9, 13], "do": [0, 3, 6, 12], "docker": [9, 12], "document": [11, 12], "doe": 3, "doesn": 6, "don": 6, "done": [3, 9], "drive": 8, "driven": 13, "dropout": 2, "dt": 9, "durat": 9, "dure": [6, 8], "e": [6, 9], "each": [6, 12, 13], "easier": 5, "easiest": 6, "easili": 1, "east": 9, "east1": 9, "eco": 13, "effect": 10, "effici": 8, "electr": [3, 6, 8, 10, 12], "els": 1, "emiss": [0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 12, 13], "emissions_endpoint": 12, "emissions_r": 9, "emissionstrack": [1, 2, 11, 12], "emissiontrack": 9, "emit": [6, 7, 8], "empir": 6, "enabl": [8, 12], "encapsul": 10, "end": [6, 10], "endpoint": [10, 12], "energi": [3, 7, 8, 9, 13], "energy_consum": 9, "enhanc": [6, 9], "enorm": 8, "entail": 8, "enter": 6, "enterpris": 3, "entir": 10, "entireti": 3, "entri": 12, "environ": [1, 5, 9, 12], "environment": [6, 7, 8], "epoch": 2, "eq": [3, 6], "equival": [6, 7, 8, 9], "eras": 10, "error": 10, "estim": [3, 6, 7, 8, 10], "etc": 11, "evalu": 9, "even": 3, "ever": [6, 13], "everi": [1, 6, 10], "everyth": [1, 12], "exampl": [1, 4, 6, 8, 9, 10, 12, 13], "execut": 13, "exemplari": 13, "exist": [3, 6, 10, 12, 13], "experi": [0, 1, 8, 10, 12, 13], "experiment_id": [0, 10, 12], "explain": 1, "explicit": 4, "explor": 13, "export": 12, "expos": 9, "express": [6, 8, 9], "face": 8, "fact": 8, "factor": [3, 6, 10], "fall": 6, "fallback": 6, "fals": [10, 12], "fast": 6, "featur": 8, "fetch": 12, "fief": 5, "file": [0, 1, 6, 9, 10, 11, 12, 13], "filehandl": 11, "filepath": 13, "filter": 11, "final": 12, "find": [3, 6], "fintetun": 7, "first": [6, 7, 9, 11, 12], "fit": 2, "flatten": 2, "float": [2, 11], "flush": [10, 12], "fn": 10, "focu": 3, "folder": 12, "follow": [2, 3, 5, 6, 7, 9, 10, 12, 13], "footprint": [1, 3, 6, 8], "forbid": 11, "forg": 5, "format": 9, "former": 10, "fossil": [6, 8], "found": [1, 6, 12], "fourth": 7, "framework": 12, "free": [1, 10], "frequent": [4, 6], "friendli": 13, "from": [0, 1, 2, 3, 4, 6, 7, 9, 10, 11, 12], "from_logit": 2, "fuel": [6, 8], "function": [3, 10, 12], "g": [6, 9], "ga": 6, "gadget": 6, "galleri": 1, "game": 8, "gase": 8, "gb": 6, "gco2": [3, 6], "gcp": 9, "geforc": 9, "gener": [6, 8, 12, 13], "geograph": 9, "geotherm": 6, "get": [0, 1, 10, 12, 13], "getlogg": 11, "github": 2, "give": 6, "given": 9, "global": [3, 6, 8, 10, 12], "global_energy_mix": 10, "globalpetrolpric": 3, "go": [1, 8, 9], "goe": [0, 12], "gold": 3, "good": [3, 6, 9], "googl": [3, 10], "google_project_nam": 11, "googlecloudloggeroutput": 11, "gpu": [0, 7, 9, 10, 12], "gpu_count": 9, "gpu_energi": 9, "gpu_id": [10, 12], "gpu_model": 9, "gpu_pow": 9, "graph": [1, 7], "great": 7, "greater": 3, "green": 10, "greenhous": 8, "grid": [6, 8, 13], "grow": 8, "gtx": 9, "h": [7, 9], "ha": [3, 6, 7, 8, 9, 12, 13], "habit": 3, "hand": 13, "handler": [10, 11], "happen": 13, "hard": 3, "hardwar": [6, 10], "have": [0, 1, 3, 6, 7, 8, 9, 10, 12], "header": 12, "help": [3, 6, 10], "here": [0, 3, 5, 6, 7, 11, 12], "hesit": 6, "hi": 10, "hierarch": 12, "histor": 9, "home": 12, "hood": 12, "host": [5, 9, 10, 12, 13], "hour": [6, 7, 8], "household": 13, "how": [3, 12], "howev": 12, "http": [4, 10, 12], "http_proxi": 12, "https_proxi": 12, "huge": 7, "human": 8, "hydroelectr": 6, "hyperparamet": 1, "i": [3, 5, 6, 8, 9, 10, 11, 12, 13], "i7": 9, "id": [0, 9, 10], "idea": 6, "iea": 3, "illustr": 13, "imag": [2, 8], "imdb": 12, "imdb_emiss": 12, "impact": [4, 8, 10], "implement": [9, 12], "import": [0, 2, 8, 11, 12], "improv": [3, 6], "inch": 13, "includ": [6, 10], "incred": 8, "index": 4, "indic": 10, "industri": 8, "infer": 12, "info": [10, 11], "inform": [3, 12, 13], "infra": 3, "infrastructur": [3, 6, 9, 10, 12, 13], "ini": 12, "init": 0, "initi": [3, 12], "input": [4, 9], "input_shap": 2, "instal": [1, 4, 6], "instanc": [10, 12], "instanti": [6, 12], "instruct": 5, "integr": 4, "intel": [6, 9], "intellig": 8, "intens": [0, 3, 4, 7, 10, 12], "interfac": [0, 9], "interfer": 12, "intern": 12, "internet": 4, "interv": [6, 9, 10], "io": 10, "iso": [9, 10, 12], "isol": 10, "issu": 3, "its": [3, 6, 7, 9, 11, 13], "itself": [5, 6], "job": 1, "json": 10, "jupyt": 12, "just": 12, "keep": [3, 12], "kei": [1, 10], "kera": 2, "kg": [6, 9], "kgco\u2082": 6, "kilogram": [6, 8], "kilowatt": [6, 8], "km": 9, "km\u00b2": 9, "known": [6, 10], "kwh": [3, 6, 7, 9], "lack": 11, "languag": 7, "larg": [7, 8], "last": [6, 12], "latest": [5, 6], "latitud": 9, "layer": 2, "lcd": 13, "learn": [2, 7, 8], "left": [1, 13], "let": 3, "letter": [9, 10, 12], "level": [8, 10, 11, 13], "leverag": [8, 11], "librari": [6, 12], "life": [3, 13], "light": [6, 7], "like": [8, 12], "line": [6, 7], "link": 1, "linux": 6, "list": [5, 6, 10, 12], "ll": 1, "load": 12, "load_data": 2, "load_dataset": 12, "local": [3, 6, 11, 12], "localhost": [9, 12], "localis": 7, "locat": [7, 10], "log": [7, 10, 13], "log_level": [10, 12], "log_nam": 11, "logfir": [4, 10], "logger": [4, 10, 13], "logger_preambl": 10, "loggeroutput": [10, 11], "logging_demo": 11, "logging_logg": [10, 11], "longitud": 9, "look": 6, "loss": 2, "loss_fn": 2, "low": [6, 10], "m": 9, "m1": 6, "m2": 6, "m3": 6, "m4": 6, "mac": 6, "machin": [0, 8, 9, 10], "macmon": 6, "made": 3, "mai": 11, "main": 6, "major": 9, "make": [1, 3, 6], "manag": [4, 5], "mandatori": 10, "mani": 3, "manner": 12, "manual": [10, 12], "map": [6, 10], "matter": 8, "measur": [6, 7, 8, 10, 12], "measure_power_sec": [0, 6, 10, 12], "memori": 6, "mention": 6, "messag": [10, 11], "metadata": 13, "method": 6, "methodologi": 4, "metric": [1, 2, 9], "microsoft": [3, 7], "might": 7, "mile": 13, "mind": 3, "minim": 12, "miss": [3, 6], "mix": [3, 6, 13], "mixtur": 6, "ml": 1, "mnist": [1, 2], "mode": [0, 4, 6, 9], "model": [2, 4, 8, 12], "model_emiss": 12, "modifi": [6, 12], "modul": 4, "monitor": [0, 6, 9, 12], "month": 8, "monthli": 3, "more": [0, 1, 6, 8, 12], "most": [7, 13], "motiv": 4, "much": 3, "multipl": 10, "multipli": 3, "must": 12, "mwh": 6, "my": 3, "my_logg": 11, "n": 9, "name": [5, 9, 10, 11, 12], "nativ": 6, "natur": 6, "nb": 7, "nearbi": 6, "need": [0, 1, 6, 9, 11, 12, 13], "neither": [3, 6], "net": [6, 13], "network": 11, "new": 10, "nice": 0, "nlp": 7, "none": [6, 10], "nopasswd": 6, "nor": 6, "normal": 12, "notabl": 3, "note": [6, 12, 13], "notebook": 12, "noth": 9, "now": [1, 6, 13], "nuclear": 6, "number": [9, 10, 13], "nvidia": [6, 9], "o": [9, 12], "object": [1, 4, 8, 10], "observ": 9, "offici": 5, "offlin": 4, "offlineemissionstrack": [9, 12], "offlineemissiontrack": 11, "offset": 3, "often": 3, "old": 10, "on_cloud": 9, "on_csv_writ": 10, "onc": [1, 9], "one": [0, 3, 9, 10, 11, 13], "onli": [3, 6, 10], "onlin": 4, "open": 3, "openapi": 0, "optim": 2, "option": [0, 3, 6, 10, 11, 12, 13], "order": [6, 8, 10, 11], "organ": 0, "organis": 13, "other": [2, 3, 8, 11], "otherwis": [6, 11], "our": [3, 6], "ourworld": 3, "out": 3, "output": [4, 11], "output_dir": [9, 10, 12], "output_fil": 10, "output_handl": 10, "overhead": [6, 12], "overrid": [10, 12], "overwrit": 12, "own": [0, 7], "p40": 7, "packag": [1, 3, 5, 6, 8, 9, 11, 13], "page": [1, 4], "panda": 5, "panel": 1, "parallel": 11, "param": 12, "paramet": [4, 6, 9, 12], "part": [6, 8], "particular": 13, "pass": [6, 12], "password": 6, "path": [6, 10, 13], "pattern": 8, "per": [6, 8, 9, 10], "perform": 8, "person": 1, "petroleum": 6, "piec": 12, "pip": [1, 5], "place": 9, "placehold": 1, "plai": [3, 8], "platform": [3, 9], "pleas": [3, 5, 6, 11, 12], "point": [7, 12, 13], "polici": 7, "popular": 7, "port": 13, "possibl": 6, "potenti": 8, "power": [1, 4, 8, 9, 10, 11, 13], "power_const": 10, "powercap": 6, "powermetr": 6, "precis": 9, "prefer": 6, "present": 7, "pretrain": 7, "prevent": 12, "preview": 13, "previou": 6, "price": 3, "print": 2, "prioriti": [3, 4], "privaci": 9, "privat": [3, 9, 11, 12], "privileg": 6, "process": [8, 9, 10, 11, 12, 13], "processor": [6, 8], "produc": [3, 8, 13], "product": 6, "program": 8, "project": [0, 2, 3, 9, 10, 11, 13], "project_nam": [2, 9, 10, 12], "prometheu": [4, 10], "prometheus_cli": 5, "prometheus_password": 9, "prometheus_url": 10, "prometheus_usernam": 9, "prompt": 12, "protect": [7, 9], "provid": [1, 6, 9, 10, 11, 12, 13], "provinc": [9, 10], "proxi": 4, "psutil": 5, "public": [0, 1, 3, 12, 13], "publish": 3, "pue": 10, "purpos": 8, "push": 9, "pushgatewai": 9, "py": [1, 5, 9, 11], "pynvml": [5, 6], "pypi": 4, "pyproject": 5, "python": [5, 12], "python_vers": 9, "quantifi": [3, 6], "quartil": 7, "question": 4, "questionari": 5, "quickstart": 4, "r": 9, "ram": 9, "ram_energi": 9, "ram_pow": 9, "ram_total_s": 9, "rang": 9, "rapidfuzz": 5, "rapl": 6, "ratio": 6, "re": 12, "read": 12, "reason": 8, "recent": 8, "recogn": [2, 3, 8], "recommend": [3, 5, 12, 13], "record": 12, "recur": 3, "reduc": [3, 9], "refer": [4, 5, 11, 12], "region": [3, 4, 9, 10, 12], "relationship": 6, "releas": 3, "relev": 7, "reli": 12, "relu": 2, "remain": 12, "remark": 8, "render": 1, "renew": 6, "replac": 1, "repo": 3, "report": [6, 11], "repositori": [2, 4], "repres": 7, "reproduc": 1, "request": [5, 12], "requir": [6, 9, 10, 12], "research": [1, 3], "resourc": 6, "respect": [9, 12], "restrict": 12, "result": [7, 9, 12], "return": [2, 12], "rich": 5, "right": [6, 7, 13], "room": 6, "root": 6, "row": 10, "rule": 9, "run": [0, 1, 3, 5, 9, 10, 12, 13], "run_id": 10, "runtim": 13, "same": [10, 12], "sampl": 1, "satisfi": 6, "save": [0, 1, 10, 11, 12], "save_to_api": [0, 10, 12], "save_to_fil": [10, 12], "save_to_logfir": [9, 10], "save_to_logg": [10, 11], "save_to_prometheu": [9, 10], "scale": 7, "schedul": [6, 12], "scheme": 3, "scientist": 1, "script": 12, "sdk": 11, "search": [1, 4, 9], "second": [6, 9, 10], "section": 12, "sector": 8, "see": [1, 6, 9, 10, 11, 12, 13], "self": 9, "send": [9, 10, 11, 12], "sent": [9, 13], "sequenti": 2, "seri": 13, "server": [0, 4, 9, 10], "servic": 9, "set": [0, 1, 9, 10, 11, 12], "setlevel": 11, "sever": 13, "share": 13, "shell": 12, "shot": 3, "should": [3, 6, 10], "show": [6, 7, 13], "shown": 13, "side": [7, 13], "sidebar": 1, "sign": 10, "signific": [6, 8], "silicon": 6, "singl": [3, 12], "small": [6, 7, 12], "so": [0, 3, 6, 9, 10, 12], "solar": 6, "some": [6, 11, 12], "soon": 12, "sophist": 8, "sourc": [3, 7], "sp0": 9, "sparsecategoricalcrossentropi": 2, "specif": [4, 6, 8, 11, 12], "specifi": [0, 9, 10, 11], "split": 12, "standard": [3, 8, 10], "start": [1, 2, 6, 9, 11, 12], "start_task": 12, "state": [8, 9, 10], "statist": 6, "stdout": 1, "still": [6, 11], "stop": [2, 6, 9, 11, 12], "stop_task": 12, "stream": 11, "string": 10, "structur": 12, "studi": 7, "subclass": 11, "subscript": 3, "success": 3, "sudo": 6, "sudoer": 6, "suffix": 9, "sum": 9, "suppli": 6, "support": [6, 10, 11, 12], "sure": 1, "sustain": 3, "switch": [6, 13], "sy": 6, "syntax": 12, "system": [1, 9, 11], "systemat": 10, "t": [6, 12], "tab": 1, "tabl": [6, 7], "taken": 1, "target": 9, "task": [8, 12], "tdp": 6, "team": 0, "tell": 0, "tensorflow": 2, "termin": 5, "test": [6, 12], "tf": 2, "than": 11, "them": [3, 6], "therefor": 3, "thermal": 6, "thi": [0, 3, 6, 7, 8, 9, 10, 11, 12, 13], "those": 13, "through": 4, "thu": 8, "ti": 9, "time": [1, 4, 6, 9, 12, 13], "timeseri": 0, "timestamp": 9, "tini": 7, "tm": 9, "token": [10, 12], "toml": 5, "tool": [1, 6, 7, 12], "toolkit": 6, "top": 13, "total": [9, 13], "track": [1, 6, 8, 9, 10, 11, 12], "track_emiss": [0, 2, 4, 12], "tracker": [2, 6, 9, 10, 11, 12], "tracking_mod": [9, 10, 12], "train": [0, 1, 2, 7, 8, 12], "train_model": [0, 2], "training_loop": 12, "transf": 7, "trigger": [9, 11], "true": [0, 2, 9, 10, 11, 12], "try": [3, 6, 10, 12], "tv": 13, "two": [0, 6, 12], "typer": 5, "typic": 11, "u": [6, 7, 9, 10], "ubiquit": 8, "ui": 1, "unchang": 12, "under": 12, "underli": [6, 8], "understand": 13, "unfortun": 3, "up": [9, 10, 12], "updat": 10, "upload": 0, "url": 10, "us": [0, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13], "usa": 9, "usabl": 11, "usag": [4, 10], "user": [6, 10, 12, 13], "usernam": 6, "usr": 6, "usual": 9, "util": 6, "uuid": 12, "v100": 7, "valid": 11, "valu": [6, 9, 10, 12], "variabl": [10, 12], "variou": [8, 11, 13], "vast": 8, "ve": 1, "verbos": 10, "version": [9, 12], "via": [3, 8], "victor": 12, "view": [1, 3], "virtual": 5, "vision": 7, "visual": [1, 4], "visudo": 6, "vit": 7, "voil\u00e0": 1, "w": 9, "wai": 12, "want": [6, 10, 12], "warm": 8, "warn": [6, 10, 12], "watch": 13, "watt": [6, 10], "we": [3, 5, 6, 8, 12], "web": [0, 12], "webhook": 9, "websit": [1, 5], "week": 8, "weekli": 13, "weight": 6, "welcom": 6, "well": 3, "what": 3, "when": [1, 3, 6, 9, 10, 12], "where": [9, 10, 12], "which": [6, 8, 10, 12], "who": 13, "wikipedia": 12, "wind": 6, "window": [6, 9], "within": 12, "without": [6, 12], "wonder": 12, "work": [3, 8, 12], "world": [3, 6], "would": [7, 8], "wrap": 12, "wren": 3, "write": 12, "written": [10, 12], "x": [9, 10], "x_test": 2, "x_train": 2, "y": 9, "y_test": 2, "y_train": 2, "year": [4, 6, 8], "yet": 12, "yield": 12, "york": 10, "you": [0, 1, 3, 6, 9, 10, 12, 13], "your": [0, 1, 3, 5, 6, 9, 10, 12, 13], "yourself": 6, "zone": 10}, "titles": ["CodeCarbon API", "Comet Integration", "Examples", "Frequently Asked Questions", "CodeCarbon", "Installing CodeCarbon", "Methodology", "Model Comparisons", "Motivation", "Output", "Parameters", "Collecting emissions to a logger", "Quickstart", "Visualize"], "titleterms": {"access": 12, "across": 6, "ai": 7, "an": 11, "api": [0, 9], "ask": 3, "authent": 11, "beta": 13, "carbon": [6, 13], "cloud": [7, 11, 13], "codecarbon": [0, 4, 5, 6, 9], "collect": 11, "comet": 1, "command": 12, "comparison": [7, 13], "conda": 5, "configur": 12, "consumpt": 7, "context": [2, 12], "countri": 13, "cpu": 6, "creat": 11, "csv": 9, "data": 9, "decor": [2, 12], "depend": 5, "detail": 13, "each": 9, "electr": [7, 13], "emiss": 11, "emissiontrack": 11, "energi": 6, "equival": 13, "exampl": [2, 11], "experi": 9, "explicit": [2, 12], "field": 9, "frequent": 3, "from": [5, 13], "get": 4, "global": 13, "googl": 11, "gpu": 6, "how": [6, 9], "http": 9, "impact": 7, "indic": 4, "input": 10, "instal": 5, "instanc": 7, "integr": 1, "intens": [6, 13], "internet": 12, "introduct": 4, "line": 12, "local": 9, "log": [4, 9, 11], "logfir": 9, "logger": [9, 11], "manag": [2, 12], "methodologi": 6, "mode": [10, 12], "model": 7, "more": 13, "motiv": 8, "object": [2, 12], "offlin": [10, 12, 13], "offlineemissionstrack": 10, "onlin": [12, 13], "output": [9, 10], "paramet": 10, "per": 13, "power": 6, "prioriti": 12, "product": 13, "prometheu": 9, "proxi": 12, "pypi": 5, "python": 11, "question": 3, "quickstart": 12, "ram": 6, "refer": [6, 7], "region": [7, 13], "repositori": 5, "server": 12, "sourc": 6, "specif": 10, "start": 4, "summari": 13, "tabl": 4, "test": 9, "through": 12, "time": 7, "track_emiss": 10, "us": [2, 9], "usag": 6, "visual": 13, "work": 6, "year": 7}}) \ No newline at end of file diff --git a/docs/to_logger.html b/docs/to_logger.html index 6cdb5cf9c..9002b120e 100644 --- a/docs/to_logger.html +++ b/docs/to_logger.html @@ -7,7 +7,7 @@ Collecting emissions to a logger — CodeCarbon 2.8.2 documentation - + @@ -112,7 +112,7 @@

    Create a logger

    Python logger

    -
    import logging
    +
    import logging
     
     # Create a dedicated logger (log name can be the CodeCarbon project name for example)
     _logger = logging.getLogger(log_name)
    @@ -132,7 +132,7 @@ 

    Python logger

    Google Cloud Logging

    -
    import google.cloud.logging
    +
    import google.cloud.logging
     
     
     # Create a Cloud Logging client (specify project name if needed, otherwise Google SDK default project name is used)
    diff --git a/docs/usage.html b/docs/usage.html
    index 74d86e794..641bfa105 100644
    --- a/docs/usage.html
    +++ b/docs/usage.html
    @@ -7,7 +7,7 @@
     
       
       Quickstart — CodeCarbon 2.8.2 documentation
    -      
    +      
           
     
       
    @@ -144,7 +144,7 @@ 

    Command line

    In the case of absence of a single entry and stop point for the training code base, users can instantiate a EmissionsTracker object and pass it as a parameter to function calls to start and stop the emissions tracking of the compute section.

    -
    from codecarbon import EmissionsTracker
    +
    from codecarbon import EmissionsTracker
     tracker = EmissionsTracker()
     tracker.start()
     try:
    @@ -177,7 +177,7 @@ 

    Explicit Object

    Context manager

    The Emissions tracker also works as a context manager.

    -
    from codecarbon import EmissionsTracker
    +
    from codecarbon import EmissionsTracker
     
     with EmissionsTracker() as tracker:
         # Compute intensive training code goes here
    @@ -189,10 +189,10 @@ 

    Context manager

    In case the training code base is wrapped in a function, users can use the decorator @track_emissions within the function to enable tracking emissions of the training code.

    -
    from codecarbon import track_emissions
    +
    from codecarbon import track_emissions
     
     @track_emissions
    -def training_loop():
    +def training_loop():
         # Compute intensive training code goes here
     
    @@ -210,7 +210,7 @@

    Offline Mode

    Explicit Object

    Developers can use the OfflineEmissionsTracker object to track emissions as follows:

    -
    from codecarbon import OfflineEmissionsTracker
    +
    from codecarbon import OfflineEmissionsTracker
     tracker = OfflineEmissionsTracker(country_iso_code="CAN")
     tracker.start()
     # GPU intensive training code
    @@ -221,7 +221,7 @@ 

    Explicit Object

    Context manager

    The OfflineEmissionsTracker also works as a context manager

    -
    from codecarbon import OfflineEmissionsTracker
    +
    from codecarbon import OfflineEmissionsTracker
     
     with OfflineEmissionsTracker() as tracker:
     # GPU intensive training code  goes here
    @@ -235,9 +235,9 @@ 

    Decorator<
  • offline needs to be set to True, which defaults to False for online mode.

  • country_iso_code the 3-letter alphabet ISO Code of the country where the compute infrastructure is hosted

  • -
    from codecarbon import track_emissions
    +
    from codecarbon import track_emissions
     @track_emissions(offline=True, country_iso_code="CAN")
    -def training_loop():
    +def training_loop():
         # training code goes here
         pass
     
    @@ -337,7 +337,7 @@

    Access internet through proxy server
    import os
    +
    import os
     
     os.environ["HTTPS_PROXY"] = "http://0.0.0.0:0000"
     
    diff --git a/docs/visualize.html b/docs/visualize.html index a61eda149..ed9974676 100644 --- a/docs/visualize.html +++ b/docs/visualize.html @@ -7,7 +7,7 @@ Visualize — CodeCarbon 2.8.2 documentation - + From 64552db9ecb1d136ced651ef6929ed5d2bc88117 Mon Sep 17 00:00:00 2001 From: LuisBlanche Date: Sat, 18 Jan 2025 12:17:30 +0100 Subject: [PATCH 11/15] feat: :sparkles: add RAM tracking from Macmon in AppleSilicon Chip --- codecarbon/core/macmon.py | 4 ++-- codecarbon/core/measure.py | 7 +++++++ codecarbon/emissions_tracker.py | 7 +++++++ codecarbon/external/hardware.py | 10 ++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/codecarbon/core/macmon.py b/codecarbon/core/macmon.py index c77697a26..da356da20 100644 --- a/codecarbon/core/macmon.py +++ b/codecarbon/core/macmon.py @@ -124,8 +124,8 @@ def get_details(self) -> Dict: details["GPU Energy Delta"] = (self._interval / 1000) * ( data["gpu_power"].astype(float) ).sum() - details["Ram Power"] = data["ram_power"].mean() - details["Ram Energy Delta"] = (self._interval / 1000) * ( + details["RAM Power"] = data["ram_power"].mean() + details["RAM Energy Delta"] = (self._interval / 1000) * ( data["ram_power"].astype(float) ).sum() except Exception as e: diff --git a/codecarbon/core/measure.py b/codecarbon/core/measure.py index 6f612a5da..3d70814f3 100644 --- a/codecarbon/core/measure.py +++ b/codecarbon/core/measure.py @@ -85,6 +85,13 @@ def do_measure(self) -> None: f"Energy consumed for AppleSilicon GPU : {self._total_gpu_energy.kWh:.6f} kWh" + f".Apple Silicon GPU Power : {self._gpu_power.W} W" ) + elif hardware.chip_part == "RAM": + self._total_ram_energy += energy + self._ram_power = power + logger.info( + f"Energy consumed for AppleSilicon RAM : {self._total_ram_energy.kWh:.6f} kWh." + + f"Apple Silicon RAM Power : {self._ram_power.W} W" + ) else: logger.error(f"Unknown hardware type: {hardware} ({type(hardware)})") h_time = perf_counter() - h_time diff --git a/codecarbon/emissions_tracker.py b/codecarbon/emissions_tracker.py index 6a5cb3fdd..2e45b8dbd 100644 --- a/codecarbon/emissions_tracker.py +++ b/codecarbon/emissions_tracker.py @@ -700,6 +700,13 @@ def _do_measurements(self) -> None: f"Energy consumed for all GPUs : {self._total_gpu_energy.kWh:.6f} kWh" + f". Total GPU Power : {self._gpu_power.W} W" ) + elif hardware.chip_part == "RAM": + self._total_ram_energy += energy + self._ram_power = power + logger.info( + f"Energy consumed for RAM : {self._total_ram_energy.kWh:.6f} kWh" + + f". RAM Power : {self._ram_power.W} W" + ) else: logger.error(f"Unknown hardware type: {hardware} ({type(hardware)})") h_time = time.perf_counter() - h_time diff --git a/codecarbon/external/hardware.py b/codecarbon/external/hardware.py index eec6feaef..65f9fd0a0 100644 --- a/codecarbon/external/hardware.py +++ b/codecarbon/external/hardware.py @@ -493,3 +493,13 @@ def from_utils( logger.warning("Could not read AppleSiliconChip model.") return cls(output_dir=output_dir, model=model, chip_part=chip_part) + + @property + def machine_memory_GB(self): + """ + Property to compute the machine's total memory in bytes. + + Returns: + float: Total RAM (GB) + """ + return psutil.virtual_memory().total / B_TO_GB From 6604c37007fa8469e92e40c616da9950cc340a98 Mon Sep 17 00:00:00 2001 From: LuisBlanche Date: Sat, 18 Jan 2025 12:17:48 +0100 Subject: [PATCH 12/15] refactor: --- codecarbon/core/resource_tracker.py | 55 +++++++++++++++++------------ 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/codecarbon/core/resource_tracker.py b/codecarbon/core/resource_tracker.py index b73ed48c8..40466e27f 100644 --- a/codecarbon/core/resource_tracker.py +++ b/codecarbon/core/resource_tracker.py @@ -16,10 +16,20 @@ def __init__(self, tracker): def set_RAM_tracking(self): logger.info("[setup] RAM Tracking...") - self.ram_tracker = "3 Watts for 8 GB ratio constant" - ram = RAM(tracking_mode=self.tracker._tracking_mode) - self.tracker._conf["ram_total_size"] = ram.machine_memory_GB - self.tracker._hardware: List[Union[RAM, CPU, GPU, AppleSiliconChip]] = [ram] + if macmon.is_macmon_available(): + logger.info("Tracking Apple RAM via MacMon") + self.ram_tracker = "MacMon" + ram = AppleSiliconChip.from_utils(self.tracker._output_dir, chip_part="RAM") + self.tracker._conf["ram_total_size"] = ram.machine_memory_GB + self.tracker._hardware: List[Union[RAM, CPU, GPU, AppleSiliconChip]] = [ram] + + else: + self.ram_tracker = "3 Watts for 8 GB ratio constant" + logger.info(f"Tracking RAM via constant ratio: {self.ram_tracker}") + + ram = RAM(tracking_mode=self.tracker._tracking_mode) + self.tracker._conf["ram_total_size"] = ram.machine_memory_GB + self.tracker._hardware: List[Union[RAM, CPU, GPU, AppleSiliconChip]] = [ram] def set_CPU_tracking(self): logger.info("[setup] CPU Tracking...") @@ -36,42 +46,26 @@ def set_CPU_tracking(self): self.tracker._hardware.append(hardware) self.tracker._conf["cpu_model"] = hardware.get_model() elif self.tracker._default_cpu_power is None and macmon.is_macmon_available(): - self.gpu_tracker = "MacMon" self.cpu_tracker = "MacMon" - logger.info(f"Tracking Apple CPU and GPU using {self.cpu_tracker}") + logger.info(f"Tracking Apple CPU using {self.cpu_tracker}") hardware_cpu = AppleSiliconChip.from_utils( self.tracker._output_dir, chip_part="CPU" ) self.tracker._hardware.append(hardware_cpu) self.tracker._conf["cpu_model"] = hardware_cpu.get_model() - hardware_gpu = AppleSiliconChip.from_utils( - self.tracker._output_dir, chip_part="GPU" - ) - self.tracker._hardware.append(hardware_gpu) - - self.tracker._conf["gpu_model"] = hardware_gpu.get_model() - self.tracker._conf["gpu_count"] = 1 elif ( self.tracker._default_cpu_power is None and powermetrics.is_powermetrics_available() ): - self.gpu_tracker = "PowerMetrics" self.cpu_tracker = "PowerMetrics" - logger.info(f"Tracking Apple CPU and GPU using {self.cpu_tracker}") + logger.info(f"Tracking Apple CPU using {self.cpu_tracker}") hardware_cpu = AppleSiliconChip.from_utils( self.tracker._output_dir, chip_part="CPU" ) self.tracker._hardware.append(hardware_cpu) self.tracker._conf["cpu_model"] = hardware_cpu.get_model() - hardware_gpu = AppleSiliconChip.from_utils( - self.tracker._output_dir, chip_part="GPU" - ) - self.tracker._hardware.append(hardware_gpu) - - self.tracker._conf["gpu_model"] = hardware_gpu.get_model() - self.tracker._conf["gpu_count"] = 1 else: # Explain what to install to increase accuracy cpu_tracking_install_instructions = "" @@ -141,6 +135,23 @@ def set_GPU_tracking(self): self.tracker._conf["gpu_count"] = len( gpu_devices.devices.get_gpu_static_info() ) + elif macmon.is_macmon_available(): + logger.info("Tracking Apple GPU via MacMon") + hardware_gpu = AppleSiliconChip.from_utils( + self.tracker._output_dir, chip_part="GPU" + ) + self.tracker._hardware.append(hardware_gpu) + self.tracker._conf["gpu_model"] = hardware_gpu.get_model() + self.tracker._conf["gpu_count"] = 1 + + elif powermetrics.is_powermetrics_available(): + logger.info("Tracking Apple GPU via PowerMetrics") + hardware_gpu = AppleSiliconChip.from_utils( + self.tracker._output_dir, chip_part="GPU" + ) + self.tracker._hardware.append(hardware_gpu) + self.tracker._conf["gpu_model"] = hardware_gpu.get_model() + self.tracker._conf["gpu_count"] = 1 else: logger.info("No GPU found.") From 120e3ac8c29276bda65184f993dd2b655d62ae2d Mon Sep 17 00:00:00 2001 From: LuisBlanche Date: Sat, 18 Jan 2025 12:28:15 +0100 Subject: [PATCH 13/15] test: :white_check_mark: fix macmon test --- tests/test_macmon.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_macmon.py b/tests/test_macmon.py index cc9ba3f0c..b792c0eaf 100644 --- a/tests/test_macmon.py +++ b/tests/test_macmon.py @@ -36,8 +36,8 @@ def test_get_details(self, mock_setup, mock_log_values): "CPU Energy Delta": np.float64(0.398248779), "GPU Power": np.float64(0.0321656683), "GPU Energy Delta": np.float64(0.0321656683), - "Ram Power": np.float64(0.0), - "Ram Energy Delta": np.float64(0.0), + "RAM Power": np.float64(0.0), + "RAM Energy Delta": np.float64(0.0), } if is_macmon_available(): macmon = MacMon( From b1f3ca88b2efe25a6d8fafddc68e4806c7c9dbe9 Mon Sep 17 00:00:00 2001 From: LuisBlanche Date: Tue, 18 Mar 2025 09:55:55 -0600 Subject: [PATCH 14/15] fix(RAM): :bug: revert to constant mode for RAM power with M1 chips macmon not correctly measuring RAM for M1 always returning 0 --- codecarbon/core/resource_tracker.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/codecarbon/core/resource_tracker.py b/codecarbon/core/resource_tracker.py index 40466e27f..6ea3d0e66 100644 --- a/codecarbon/core/resource_tracker.py +++ b/codecarbon/core/resource_tracker.py @@ -16,7 +16,8 @@ def __init__(self, tracker): def set_RAM_tracking(self): logger.info("[setup] RAM Tracking...") - if macmon.is_macmon_available(): + + if macmon.is_macmon_available() and "M1" not in detect_cpu_model(): logger.info("Tracking Apple RAM via MacMon") self.ram_tracker = "MacMon" ram = AppleSiliconChip.from_utils(self.tracker._output_dir, chip_part="RAM") @@ -24,6 +25,10 @@ def set_RAM_tracking(self): self.tracker._hardware: List[Union[RAM, CPU, GPU, AppleSiliconChip]] = [ram] else: + if macmon.is_macmon_available(): + logger.warning( + "MacMon is installed but cannot track RAM power on M1 chips, reverting to constant RAM power" + ) self.ram_tracker = "3 Watts for 8 GB ratio constant" logger.info(f"Tracking RAM via constant ratio: {self.ram_tracker}") From f163530ebf07390d2cd126bc199f7f40e4684569 Mon Sep 17 00:00:00 2001 From: LuisBlanche Date: Sat, 19 Apr 2025 12:40:23 +0200 Subject: [PATCH 15/15] fix(RAM): :bug: remove default_cpu_power --- codecarbon/core/resource_tracker.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/codecarbon/core/resource_tracker.py b/codecarbon/core/resource_tracker.py index cc21c4037..509455fd1 100644 --- a/codecarbon/core/resource_tracker.py +++ b/codecarbon/core/resource_tracker.py @@ -100,13 +100,10 @@ def set_CPU_tracking(self): "The RAPL energy and power reported is divided by 2 for all 'AMD Ryzen Threadripper' as it seems to give better results." ) # change code to check if powermetrics needs to be installed or just sudo setup - elif self.tracker._default_cpu_power is None and macmon.is_macmon_available(): + elif macmon.is_macmon_available(): self.cpu_tracker = "MacMon" logger.info(f"Tracking Apple CPU using {self.cpu_tracker}") - elif ( - self.tracker._default_cpu_power is None - and powermetrics.is_powermetrics_available() - ): + elif powermetrics.is_powermetrics_available(): self.cpu_tracker = "PowerMetrics" logger.info(f"Tracking Apple CPU using {self.cpu_tracker}") hardware_cpu = AppleSiliconChip.from_utils(