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.

Usage of Eco2AI

An example of using the library is given in the publication. It the paper we presented experiments of tracking equivalent CO2 emissions using eco2AI while training ruDALL-E models with with 1.3 billion (Malevich, ruDALL-E XL 1.3B) and 12 billion parameters (Kandinsky, ruDALL-E XL 12B). These are multimodal pre-trained transformers that learn the conditional distribution of images with by some string of text capable of generating arbitrary images from a russian text prompt that describes the desired result. Properly accounted carbon emissions and power consumption Malevich and Kandinsky fine-tuning Malevich and Kandinsky on the Emojis dataset is given in the table below.

Model Train time Power, kWh CO2, kg GPU CPU Batch Size
Malevich 4h 19m 1.37 0.33 A100 Graphics, 1 AMD EPYC 7742 64-Core 4
Kandinsky 9h 45m 24.50 5.89 A100 Graphics, 8 AMD EPYC 7742 64-Core 12

Also we presented results for training of Malevich with optimized variation of GELU activation function. Training of the Malevich with the 8-bit version of GELU allows us to spent about 10% less energy and, consequently, produce less equivalent CO2 emissions.

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:

@misc{https://doi.org/10.48550/arxiv.2208.00406,
  doi = {10.48550/ARXIV.2208.00406},
  
  url = {https://arxiv.org/abs/2208.00406},
  
  author = {Budennyy, Semen and Lazarev, Vladimir and Zakharenko, Nikita and Korovin, Alexey and Plosskaya, Olga and Dimitrov, Denis and Arkhipkin, Vladimir and Oseledets, Ivan and Barsola, Ivan and Egorov, Ilya and Kosterina, Aleksandra and Zhukov, Leonid},
  
  keywords = {Machine Learning (cs.LG), Artificial Intelligence (cs.AI), Computational Engineering, Finance, and Science (cs.CE), Computers and Society (cs.CY), FOS: Computer and information sciences, FOS: Computer and information sciences},
  
  title = {Eco2AI: carbon emissions tracking of machine learning models as the first step towards sustainable AI},
  
  publisher = {arXiv},
  
  year = {2022},
  
  copyright = {arXiv.org perpetual, non-exclusive license}
}

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

Uploaded Source

Built Distribution

eco2ai-0.3.4-py2.py3-none-any.whl (107.2 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: eco2ai-0.3.4.tar.gz
  • Upload date:
  • Size: 108.5 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.4.tar.gz
Algorithm Hash digest
SHA256 faed938d82c9967adfe58dbb463949abe56afc8511babd91071455fe45b7dfc0
MD5 76f3ff538e661296e2aef2797bc63487
BLAKE2b-256 3c387664f17e100f2b2286f66de67a3ce85e7fd0ead5c02a7d75b59aa9699ccd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: eco2ai-0.3.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 107.2 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.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7712b87d447d0b284593f2c343e19b16681efde83230955f3143ce98b139ce42
MD5 8e776c619e8b15cd0d90b5400aeb791e
BLAKE2b-256 c214574a0e8b42c852cbe95d5233547f3cebc4169dac3ded2fb6ce07b80f4aa2

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