Skip to main content

A lightweight package to measure the ecological and financial effect of training and evaluation of pytorch projects.

Project description

EcoTorch

A lightweight, plug-and-play tool to measure the ecological impact and efficiency of your PyTorch models.

EcoTorch runs in the background while your models learn or get tested. It tracks exactly how much power your machine uses, figures out your carbon footprint based on your location, and gives you a final efficiency score. It works seamlessly across Mac, Windows, and Linux.

Installation

You can grab the tool directly from the public Python store. Open your terminal and type:

pip install ecotorch

Quick Start

You do not need to rewrite any of your existing work to use EcoTorch. Just wrap your normal learning or testing loops inside the TrainTracker and EvalTracker.

Quick example:

import torch
from ecotorch import TrainTracker, EvalTracker, Mode

# Set up your model and data
model = ...
train_loader = ... 
test_loader = ...
epoch = ...

# Wrap your train loop in the TrainTracker
with TrainTracker(epochs=epoch, model=model, train_dataloader=train_loader) as train_tracker:
    # Training logic...
    initial_loss = 2.5
    final_loss = 0.5

# Final score
score = train_tracker.calculate_efficiency_score(initial_loss=initial_loss, final_loss=final_loss)
print(f"Efficiency Score: {score}")

# You can track evaluation and inference
with EvalTracker(test_dataloader=test_loader, train_tracker=train_tracker) as eval_tracker:
    # Evaluation logic...
    acc = 0.9

# Final score
score = eval_tracker.calculate_efficiency_score(accuracy=acc)
print(f"Efficiency Score: {score}")

A fully implemented example is available in testing.py

How It Works

When you start the tracker, it automatically:

  • Finds your location: It checks where you are in the world to find out how clean your local power grid is.
  • Reads the power meter: It taps directly into your machine's graphics chip or Apple brain to read the exact power drops being used.
  • Does the math: When the block finishes, it calculates your total energy used (kWh), your emitted carbon (grams of CO2), and a final efficiency score based on how much your model improved versus how much energy it burned.

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

ecotorch-0.2.4.tar.gz (2.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ecotorch-0.2.4-cp313-cp313-macosx_26_0_arm64.whl (2.6 MB view details)

Uploaded CPython 3.13macOS 26.0+ ARM64

File details

Details for the file ecotorch-0.2.4.tar.gz.

File metadata

  • Download URL: ecotorch-0.2.4.tar.gz
  • Upload date:
  • Size: 2.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.19

File hashes

Hashes for ecotorch-0.2.4.tar.gz
Algorithm Hash digest
SHA256 7a5ce00ff8c32988dff881b83a90dd927bdf7e5956f9d49d002c2403750e9d9e
MD5 c18dcaf33f733836480f981ea306c336
BLAKE2b-256 246354d673a44e2424da0d64b0d37f35f9909febc4ee34652cbcb5b772c802ee

See more details on using hashes here.

File details

Details for the file ecotorch-0.2.4-cp313-cp313-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for ecotorch-0.2.4-cp313-cp313-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 dec26549e76afb6002c9f7dd122d6f7b1361834ef6b4242b20861e9eb022e67b
MD5 a34d16973e04cfb0e9b38e0fb37e886e
BLAKE2b-256 2e5ab2c84e1ced16e500a493866117a1f414deb22a087f04c57d2274f92d4c5f

See more details on using hashes here.

Supported by

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