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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a5ce00ff8c32988dff881b83a90dd927bdf7e5956f9d49d002c2403750e9d9e
|
|
| MD5 |
c18dcaf33f733836480f981ea306c336
|
|
| BLAKE2b-256 |
246354d673a44e2424da0d64b0d37f35f9909febc4ee34652cbcb5b772c802ee
|
File details
Details for the file ecotorch-0.2.4-cp313-cp313-macosx_26_0_arm64.whl.
File metadata
- Download URL: ecotorch-0.2.4-cp313-cp313-macosx_26_0_arm64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.13, macOS 26.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dec26549e76afb6002c9f7dd122d6f7b1361834ef6b4242b20861e9eb022e67b
|
|
| MD5 |
a34d16973e04cfb0e9b38e0fb37e886e
|
|
| BLAKE2b-256 |
2e5ab2c84e1ced16e500a493866117a1f414deb22a087f04c57d2274f92d4c5f
|