Skip to main content

A Python package to track energy consumption and CO2 emissions for LLM models and other computational tasks.

Project description

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

energy_tracker-0.3.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

energy_tracker-0.3.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file energy_tracker-0.3.0.tar.gz.

File metadata

  • Download URL: energy_tracker-0.3.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for energy_tracker-0.3.0.tar.gz
Algorithm Hash digest
SHA256 83bfcf9d3d603b933b8794400740b59cee6ff77e6603b0a13dd7c00bae6e10a3
MD5 f43a25f28d56f14cc4d873383438f4a5
BLAKE2b-256 0a4f483bbf46bd1285c9f4172a802dabf47afa25f49d5147951c950d59e818f1

See more details on using hashes here.

File details

Details for the file energy_tracker-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: energy_tracker-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for energy_tracker-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0cca391e4487709b93ad557f9911e87601f0266c5bf703ebb98eb661a0cfc28a
MD5 7518dab12ff973ccf14cb9bc7df1ec1e
BLAKE2b-256 8d4bb07b8e78f13609ba2f72873f57f284bbfdacb2023e8ba68eb6433424fbc1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page