Skip to main content

Energy Tracker

A Python package to track energy consumption and CO2 emissions for LLM models and other computational tasks. The package provides tools to track power usage of both CPU and GPU, as well as track system memory usage. It also estimates CO2 emissions based on energy consumption.

Features

  • Tracks CPU power usage
  • Tracks GPU power usage (NVIDIA GPUs only)
  • Tracks memory usage
  • Estimates CO2 emissions based on energy consumption

Installation

You can install the package using pip:

pip install energy-tracker

Usage

You can use the EnergyTracker class to start tracking energy consumption and CO2 emissions:

Simple Usage

from energy_tracker.tracker import EnergyTracker

# Initialize the energy tracker
tracker = EnergyTracker()

# Log energy consumption data
tracker.log_energy_consumption()

# Stop the emissions tracker and get CO2 emissions
tracker.stop_tracker()

# Shutdown the tracker
tracker.shutdown()

LLM Usage

from transformers import pipeline
from energy_tracker.tracker import EnergyTracker

# Load LLM
llm = pipeline("text-generation", model="gpt2")

# Initialize energy tracker
tracker = EnergyTracker()

try:
    # Tracks energy during inference
    print("Running LLM inference...")
    tracker.log_energy_consumption()
    result = llm("What is the capital of France?", max_length=10)
    print(result)
    tracker.log_energy_consumption()
finally:
    tracker.shutdown()

Requirements

  • Python 3.6+
  • psutil
  • pynvml (for NVIDIA GPU monitoring)
  • codecarbon (for CO2 emissions tracking)

Metadata

Release files for energy-tracker 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for energy-tracker 0.3.0
File Size Uploaded Provenance Actions
energy_tracker-0.3.0.tar.gz 5.2 kB Without provenance Details for energy_tracker-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for energy-tracker 0.3.0
File Interpreter ABI Platform Actions
energy_tracker-0.3.0-py3-none-any.whl Python 3 none any Details for energy_tracker-0.3.0-py3-none-any.whl

Total release size: 11.9 kB

Release files / energy_tracker-0.3.0.tar.gz

Download URL energy_tracker-0.3.0.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
83bfcf9d3d603b933b8794400740b59cee6ff77e6603b0a13dd7c00bae6e10a3
BLAKE2b-256 checksum
How to use checksums
0a4f483bbf46bd1285c9f4172a802dabf47afa25f49d5147951c950d59e818f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / energy_tracker-0.3.0-py3-none-any.whl

Download URL energy_tracker-0.3.0-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0cca391e4487709b93ad557f9911e87601f0266c5bf703ebb98eb661a0cfc28a
BLAKE2b-256 checksum
How to use checksums
8d4bb07b8e78f13609ba2f72873f57f284bbfdacb2023e8ba68eb6433424fbc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Security for energy-tracker 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page