Skip to main content

emission tracking library

Project description

PyPI Downloads PyPI all Downloads

PyPI - Downloads PyPI - Downloads DOI 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 taking into account the regional emission coefficient. 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

To install the eco2ai library, run the following command:

pip install eco2ai

Use examples

Example usage eco2ai Open In Collab

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. Each 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

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.

Citing Eco2AI

DOI

The Eco2AI is licensed under a Apache licence 2.0.

Please consider citing the following paper in any research manuscript using the Eco2AI library:

@article{eco2ai_lib,
    author = {Semen Budennyy*, Vladimir Lazarev, Nikita Zakharenko, Alexey Korovin, Olga Plosskaya, Denis Dimitrov, Vladimir Arkhipkin, Ivan Barsola, Ilya Egorov, Aleksandra Kosterina, Leonid Zhukov
    
},
    title = {eco2AI: open-source library for carbon emission tracking of machine learning models},
    year = {2022},
    journal={arXiv preprint arXiv:2208.00406},
}

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.3.1.tar.gz (106.9 kB view details)

Uploaded Source

Built Distribution

eco2ai-0.3.1-py2.py3-none-any.whl (106.1 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for eco2ai-0.3.1.tar.gz
Algorithm Hash digest
SHA256 a6e25c1996205180b9b4a7b6597471930cb6dd25c1004f7e5b3b96f5b22995c6
MD5 5547780727400a69aec5064f2a5bbf5d
BLAKE2b-256 68362fbe05786fb285c447e5312e302363ed90374e2e41fb260ac82263b12678

See more details on using hashes here.

File details

Details for the file eco2ai-0.3.1-py2.py3-none-any.whl.

File metadata

  • Download URL: eco2ai-0.3.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 106.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.9.7 Darwin/20.4.0

File hashes

Hashes for eco2ai-0.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e981eb4109b1b72e8776da6e7330c4bcddd53f59f7233216da8b17fd6d1a1d9c
MD5 7ecb69987f1e99f838e97aa8cc7750ac
BLAKE2b-256 81d555035e234c9251d49bc659efb9b024c6242cc150c26cf3abc5e38de3bea0

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