{"slug": "tracarbon-track-gpu-power-and-carbon-emissions-while-running-local-llms", "title": "Tracarbon: Track GPU power and carbon emissions while running local LLMs", "summary": "Tracarbon, a Python library that tracks device energy consumption and calculates carbon emissions, now supports monitoring GPU power and carbon output while running local large language models. It detects the user's location and device automatically and exports measurements via CLI or API to exporters such as Prometheus and Datadog. The library covers Apple Silicon, Linux (Intel/AMD), and Windows NVIDIA GPUs, with cloud provider support for AWS, GCP, and Azure.", "body_md": "Tracarbon is a Python library that tracks your device's energy consumption and calculates your carbon emissions.\n\nIt detects your location and your device automatically before starting to export measurements to an exporter. It could be used as a CLI with already defined metrics or programmatically with the API by defining the metrics that you want to have.\n\nRead more in this [article](https://medium.com/@florian.valeye/tracarbon-track-your-devices-carbon-footprint-fb051fcc9009).\n\n```\n# Install Tracarbon\npip install tracarbon\n# Install one or more exporters from the list\npip install 'tracarbon[datadog,prometheus,kubernetes]'\n```\n\n| **Devices** | **Description** | \n|---|---|\n| Mac | ✅ Apple Silicon CPU, GPU, memory and Neural Engine energy via IOReport (no sudo). Excludes display and peripherals. Fallbacks: `powermetrics` (sudo), then`ioreg` . | \n| Linux | ✅ Supports Intel and AMD processors via [RAPL](https://web.eece.maine.edu/~vweaver/projects/rapl/) . Intel uses the powercap interface. AMD is supported on kernel 5.8+ (powercap) or via the`amd_energy` driver (HWMON). Works with containers on[Kubernetes](https://kubernetes.io/) using the[Metric API](https://kubernetes.io/docs/tasks/debug/debug-cluster/resource-metrics-pipeline/#metrics-api) if available. | \n| Windows | ✅ NVIDIA GPU power via `nvidia-smi` . CPU, memory and host totals are unavailable. | \n\n| **Cloud Provider** | **Description** | \n|---|---|\n| AWS | ✅ Use the hardware's usage with the EC2 instances carbon emissions datasets of [cloud-carbon-coefficients](https://github.com/cloud-carbon-footprint/ccf-coefficients/blob/main/data/aws-instances.csv) . | \n| GCP | ✅ Use the hardware's usage with the GCP instances carbon emissions datasets of [cloud-carbon-coefficients](https://github.com/cloud-carbon-footprint/ccf-coefficients/blob/main/data/gcp-instances.csv) . | \n| Azure | ✅ Use the hardware's usage with the Azure instances carbon emissions datasets of [cloud-carbon-coefficients](https://github.com/cloud-carbon-footprint/ccf-coefficients/blob/main/data/azure-instances.csv) . | \n\n| **GPU** | **Description** | \n|---|---|\n| NVIDIA | ✅ Supported via `nvidia-smi` . Works on Linux, Windows, and Intel Macs. Supports multiple GPUs. | \n| AMD | ✅ Supported via `rocm-smi` or`amd-smi` on Linux. Supports multiple GPUs. | \n| Apple Silicon | ✅ Integrated GPU power via IOReport, without sudo. Falls back to `powermetrics` (requires sudo). | \n| Intel | ❌ Not yet implemented. | \n\n| **Exporter** | **Description** | \n|---|---|\n| Stdout | Print the metrics in Stdout. | \n| JSON | Write the metrics in a JSON file. | \n| Prometheus | Send the metrics to Prometheus. | \n| Datadog | Send the metrics to Datadog. | \n\n| **Location** | **Description** | **Source** | \n|---|---|---|\n| Worldwide | Get the latest co2g/kwh in near real-time using the CO2Signal or ElectricityMaps APIs. See [here](https://app.electricitymaps.com/developer-hub/api/reference) for available Electricity Maps query modes. | [CO2Signal API](https://www.co2signal.com) or[ElectricityMaps](https://app.electricitymaps.com/developer-hub/api/reference) | \n| Europe | Static file created from the European Environment Agency Emission for the co2g/kwh in European countries. | [EEA website](https://www.eea.europa.eu/en/analysis/maps-and-charts/co2-emission-intensity-15) | \n| AWS | Static file of the AWS Grid emissions factors. | [cloud-carbon-coefficients](https://github.com/cloud-carbon-footprint/cloud-carbon-coefficients/blob/main/data/grid-emissions-factors-aws.csv) | \n| GCP | Static file of the GCP Grid emissions factors (2024 yearly data). | [GoogleCloudPlatform/region-carbon-info](https://github.com/GoogleCloudPlatform/region-carbon-info/blob/main/data/yearly/2024.csv) | \n| Azure | Static file of the Azure Grid emissions factors. | [cloud-carbon-coefficients](https://github.com/cloud-carbon-footprint/cloud-carbon-coefficients/blob/main/data/grid-emissions-factors-azure.csv) | \n\nThe environment variables can be set from an environment file `.env`.\n\n| **Parameter** | **Description** | \n|---|---|\n| TRACARBON_CO2SIGNAL_API_KEY | The api key received from [CO2Signal](https://www.co2signal.com) or[ElectricityMaps](https://app.electricitymaps.com/developer-hub/api/reference) . | \n| TRACARBON_CO2SIGNAL_URL | The url of [CO2Signal](https://docs.co2signal.com/#get-latest-by-country-code) is the default endpoint to retrieve the last known state of the zone, but it could be changed to[ElectricityMaps](https://app.electricitymaps.com/developer-hub/api/reference) . | \n| TRACARBON_METRIC_PREFIX_NAME | The prefix to use in all the metrics name. | \n| TRACARBON_INTERVAL_IN_SECONDS | The interval in seconds to wait between the metrics evaluation. | \n| TRACARBON_LOG_LEVEL | The level to use for displaying the logs. | \n| TRACARBON_IPINFO_TOKEN | An optional [ipinfo.io](https://ipinfo.io) API token used for country detection from the IP address, lifting the anonymous rate limit. | \n| TRACARBON_KUBERNETES_NODE_NAME | The Kubernetes node name used to scope container metrics to the node being measured. Falls back to `NODE_NAME` when unset. | \n\n**Request your API key**\n\n- Go to [CO2Signal](https://www.co2signal.com/) and get your free API key for non-commercial use, or go to[ElectricityMaps](https://app.electricitymaps.com/developer-hub/api/reference) for commercial use.\n- This API is used to retrieve the last known carbon intensity (in gCO2eq/kWh) of electricity consumed in your location.\n- Set your API key in the environment variables, in the `.env` file or directly in the configuration.\n- If you would like to start without an API key, it's possible, the carbon intensity will be loaded statistically from a file.\n- Launch Tracarbon 🚀\n\n**Command Line**\n\n```\ntracarbon run\n```\n\n**Prometheus with Kubernetes containers**\n\n```\ntracarbon run --exporter-name Prometheus --containers\n```\n\nWith the default metric prefix, container metrics are exposed with these Prometheus names:\n\n| **Metric** | **Labels** | \n|---|---|\n| tracarbon_energy_consumption_kubernetes_total | pod_name, pod_namespace, container_name, platform, containers, location, units | \n| tracarbon_energy_consumption_kubernetes_cpu | pod_name, pod_namespace, container_name, platform, containers, location, units | \n| tracarbon_energy_consumption_kubernetes_memory | pod_name, pod_namespace, container_name, platform, containers, location, units | \n| tracarbon_carbon_emission_kubernetes_total | pod_name, pod_namespace, container_name, platform, containers, location, source, units | \n| tracarbon_carbon_emission_kubernetes_cpu | pod_name, pod_namespace, container_name, platform, containers, location, source, units | \n| tracarbon_carbon_emission_kubernetes_memory | pod_name, pod_namespace, container_name, platform, containers, location, source, units | \n\nZero values are exported. If Kubernetes returns no pod metrics, the CLI logs `No Kubernetes container metrics were collected.` Host metrics are still exported.\n\nWhen running in Kubernetes, deploy Tracarbon per node and set `NODE_NAME` from `spec.nodeName` with the Downward API so container metrics are scoped to the measured node.\n\n**API**\n\n``` python\nfrom tracarbon import TracarbonBuilder, TracarbonConfiguration\n\nconfiguration = TracarbonConfiguration() # Your configuration\ntracarbon = TracarbonBuilder(configuration=configuration).build()\ntracarbon.start()\n# Your code\ntotal_co2g = tracarbon.stop() # The CO2 grams emitted while it was running\n\nwith tracarbon:\n    # Your code\n\nreport = tracarbon.report # Get the report\nprint(report.total_co2g)\n```\n\n`total_co2g` is `None` when no host carbon emission metric was collected. The total reflects collected samples.\n\n**Local: using uv**\n\n```\nmake init\nmake test-unit\n```\n\nThe documentation is hosted here: [https://fvaleye.github.io/tracarbon/documentation](https://fvaleye.github.io/tracarbon/documentation)\n\n- 2025-11 [Carbon Emission Quantification of Machine Learning: A Review](https://doi.org/10.1109/TSUSC.2025.3578834)\n- 2025-04-25 [A Critical Analysis of Machine Learning Eco-feedback Tools through the Lens of Sustainable HCI](https://doi.org/10.1145/3706598.3713198)\n- 2025-04-25 [\"Should I choose a smaller model?\": Understanding ML Model Selection and Its Impact on Sustainability](https://doi.org/10.1145/3706598.3713240)\n- 2024-07-08 [Balancing computational chemistry's potential with its environmental impact](https://doi.org/10.1039/D4GC01745E)\n- 2023-06-26 [GREENER principles for environmentally sustainable computational science](https://doi.org/10.1038/s43588-023-00461-y)\n- 2023-01-19 [eco2AI: Carbon Emissions Tracking of Machine Learning Models as the First Step Towards Sustainable AI](https://doi.org/10.1134/S1064562422060230)", "url": "https://wpnews.pro/news/tracarbon-track-gpu-power-and-carbon-emissions-while-running-local-llms", "canonical_source": "https://github.com/fvaleye/tracarbon", "published_at": "2026-09-07 14:12:10+00:00", "updated_at": "2026-09-07 14:27:50.145409+00:00", "lang": "en", "topics": ["developer-tools", "ai-infrastructure", "artificial-intelligence"], "entities": ["Tracarbon", "Prometheus", "Datadog", "Kubernetes", "NVIDIA", "AMD", "Apple Silicon", "AWS"], "alternates": {"html": "https://wpnews.pro/news/tracarbon-track-gpu-power-and-carbon-emissions-while-running-local-llms", "markdown": "https://wpnews.pro/news/tracarbon-track-gpu-power-and-carbon-emissions-while-running-local-llms.md", "text": "https://wpnews.pro/news/tracarbon-track-gpu-power-and-carbon-emissions-while-running-local-llms.txt", "jsonld": "https://wpnews.pro/news/tracarbon-track-gpu-power-and-carbon-emissions-while-running-local-llms.jsonld"}}