Skip to main content

emission tracking library

Project description

PyPI - Downloads PyPI - Downloads PyPI - Downloads telegram support

Eco2AI

About Eco2AI :clipboard:

The Eco2AI is a python library for CO2 emission tracking. It monitors energy consumption of CPU & GPU devices and estimates equivalent carbon emissions. The Eco2AI is applicable to all python scripts and all you need is to add the couple of strings to your code. All emissions data and information about your devices are recorded in a local file.

Every single run of Tracker() accompanies by a session description added to the log file, including the following elements:

  • project_name
  • experiment_description
  • start_time
  • duration(s)
  • power_consumption(kWTh)
  • CO2_emissions(kg)
  • CPU_name
  • GPU_name
  • OS
  • country

Installation :wrench:

To install the eco2ai library, run the following command:

pip install eco2ai

Use examples :computer:

The eco2ai interface is quite simple. Here is the simplest usage example:

import eco2ai

tracker = eco2ai.Tracker(project_name="YourProjectName", experiment_description="training the <your model> model")

tracker.start()

<your gpu &(or) cpu calculations>

tracker.stop()

The eco2ai also supports decorators. As soon as the decorated function is executed, the information about the emissions will be written to the emission.csv file:

from eco2ai import track

@track
def train_func(model, dataset, optimizer, epochs):
    ...

train_func(your_model, your_dataset, your_optimizer, your_epochs)

For your convenience, every time you instantiate the Tracker object with your custom parameters, these settings will be saved until the library is deleted. Eeach new tracker will be created with your custom settings (if you create a tracker with new parameters, they will be saved instead of the old ones). For example:

import eco2ai

tracker = eco2ai.Tracker(
    project_name="YourProjectName", 
    experiment_description="training <your model> model",
    file_name="emission.csv"
    )

tracker.start()
<your gpu &(or) cpu calculations>
tracker.stop()

...

# now, we want to create a new tracker for new calculations
tracker = eco2ai.Tracker()
# now, it's equivalent to:
# tracker = eco2ai.Tracker(
#     project_name="YourProjectName", 
#     experiment_description="training the <your model> model",
#     file_name="emission.csv"
# )
tracker.start()
<your gpu &(or) cpu calculations>
tracker.stop()

You can also set parameters using the set_params() function, as in the example below:

from eco2ai import set_params, Tracker

set_params(
    project_name="My_default_project_name",
    experiment_description="We trained...",
    file_name="my_emission_file.csv"
)

tracker = Tracker()
# now, it's equivelent to:
# tracker = Tracker(
#     project_name="My_default_project_name",
#     experiment_description="We trained...",
#     file_name="my_emission_file.csv"
# )
tracker.start()
<your code>
tracker.stop()

Important note :blue_book:

If for some reasons it is not possible to define country, then emission coefficient is set to 436.529kg/MWh, which is global average. Global Electricity Review

For proper calculation of gpu and cpu power consumption, you should create a "Tracker" before any gpu or CPU usage.

Create a new “Tracker” for every new calculation.

Feedback :envelope:

If you have any problems working with our tracker, please make comments on document

In collaboration with

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

eco2ai-0.2.2.tar.gz (44.2 kB view details)

Uploaded Source

Built Distribution

eco2ai-0.2.2-py3-none-any.whl (43.0 kB view details)

Uploaded Python 3

File details

Details for the file eco2ai-0.2.2.tar.gz.

File metadata

  • Download URL: eco2ai-0.2.2.tar.gz
  • Upload date:
  • Size: 44.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.7.13 Darwin/20.4.0

File hashes

Hashes for eco2ai-0.2.2.tar.gz
Algorithm Hash digest
SHA256 a381dda0cffd5f8b7f355235d02d2fd85f71233a1c68b81c6052d3a6158d9a53
MD5 a65aa835a9866fc98c11d42f2b5f3e2e
BLAKE2b-256 f63ae3829cb11d4eccf5917583df849e9199004ac4949faaaf813f1ef9807ab9

See more details on using hashes here.

File details

Details for the file eco2ai-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: eco2ai-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 43.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.7.13 Darwin/20.4.0

File hashes

Hashes for eco2ai-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cd185045d4bab69b16a4e212833f0a1ab641d35db478fee9c76d40fcf074af6b
MD5 f4ea63dc3065d91d2b129100d93c8400
BLAKE2b-256 7fab98a14c58611ad2bb6f83f7771585b4513254a48bc92d186b2767322ce7ea

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