eco2ai

eco2AI is a python library which accumulates statistics about power consumption and CO2 emission during running code.

https://github.com/sb-ai-lab/eco2ai

Science Score: 49.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 5 DOI reference(s) in README
  • Academic publication links
    Links to: arxiv.org, springer.com
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.3%) to scientific vocabulary

Keywords

ai carbon-emissions carbon-footprint co2-emissions co2-monitoring deep-learning emission-tracker energy-consumption environment esg ghg machine-learning power-consumption-measurement python sustainability
Last synced: 6 months ago · JSON representation

Repository

eco2AI is a python library which accumulates statistics about power consumption and CO2 emission during running code.

Basic Info
  • Host: GitHub
  • Owner: sb-ai-lab
  • License: apache-2.0
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 2.71 MB
Statistics
  • Stars: 259
  • Watchers: 5
  • Forks: 21
  • Open Issues: 3
  • Releases: 2
Topics
ai carbon-emissions carbon-footprint co2-emissions co2-monitoring deep-learning emission-tracker energy-consumption environment esg ghg machine-learning power-consumption-measurement python sustainability
Created over 3 years ago · Last pushed 12 months ago
Metadata Files
Readme License

README.md

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 You can also find eco2AI tutorial on youtube utube

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

```python

import eco2ai

tracker = eco2ai.Tracker(projectname="YourProjectName", experimentdescription="training the model")

tracker.start()

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:

```python from eco2ai import track

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

trainfunc(yourmodel, yourdataset, youroptimizer, 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:

```python import eco2ai

tracker = eco2ai.Tracker( projectname="YourProjectName", experimentdescription="training model", file_name="emission.csv" )

tracker.start() 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 model",

file_name="emission.csv"

)

tracker.start() tracker.stop()

```

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

```python from eco2ai import set_params, Tracker

setparams( projectname="Mydefaultprojectname", experimentdescription="We trained...", filename="myemission_file.csv" )

tracker = Tracker()

now, it's equivelent to:

tracker = Tracker(

projectname="Mydefaultprojectname",

experiment_description="We trained...",

filename="myemission_file.csv"

)

tracker.start() 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:

@article{eco2AI, title={eco2AI: Carbon Emissions Tracking of Machine Learning Models as the First Step Towards Sustainable AI}, url={https://doi.org/10.1134/S1064562422060230}, DOI={10.1134/S1064562422060230}, journal={Doklady Mathematics}, author={Budennyy, S. A. and Lazarev, V. D. and Zakharenko, N. N. and Korovin, A. N. and Plosskaya, O. A. and Dimitrov, D. V. and Akhripkin, V. S. and Pavlov, I. V. and Oseledets, I. V. and Barsola, I. S. and Egorov, I. V. and Kosterina, A. A. and Zhukov, L. E.}, year={2023}, month=jan, language={en}}

In collaboration with

Owner

  • Name: sb-ai-lab
  • Login: sb-ai-lab
  • Kind: organization

We aim to share our AI-based solutions for both scientific and industrial purposes. Hope you will find them useful and we’d appreciate much any feedback.

GitHub Events

Total
  • Create event: 2
  • Issues event: 3
  • Release event: 2
  • Watch event: 29
  • Issue comment event: 4
  • Push event: 7
  • Pull request event: 5
  • Pull request review event: 1
  • Fork event: 3
Last Year
  • Create event: 2
  • Issues event: 3
  • Release event: 2
  • Watch event: 29
  • Issue comment event: 4
  • Push event: 7
  • Pull request event: 5
  • Pull request review event: 1
  • Fork event: 3

Committers

Last synced: 6 months ago

All Time
  • Total Commits: 168
  • Total Committers: 6
  • Avg Commits per committer: 28.0
  • Development Distribution Score (DDS): 0.5
Past Year
  • Commits: 5
  • Committers: 2
  • Avg Commits per committer: 2.5
  • Development Distribution Score (DDS): 0.4
Top Committers
Name Email Commits
vladimir-laz v****9@g****m 84
Никита Николаевич n****o@y****u 62
Alex Korovin a****n@g****m 17
parohod b****n@g****m 2
Коровин Алексей k****n@a****t 2
fwcd f****l@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 6
  • Total pull requests: 7
  • Average time to close issues: 2 months
  • Average time to close pull requests: 5 months
  • Total issue authors: 6
  • Total pull request authors: 5
  • Average comments per issue: 1.5
  • Average comments per pull request: 0.29
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 3
  • Average time to close issues: 6 days
  • Average time to close pull requests: less than a minute
  • Issue authors: 1
  • Pull request authors: 2
  • Average comments per issue: 3.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • Mirual (1)
  • Dimario49 (1)
  • luciabouzaheguerte (1)
  • PeterHartog (1)
  • fatma-laribi (1)
Pull Request Authors
  • ada0l (3)
  • alexnkorovin (3)
  • fwcd (2)
  • beiyonder (2)
  • ioannismavromatis (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 319 last-month
  • Total dependent packages: 3
  • Total dependent repositories: 1
  • Total versions: 22
  • Total maintainers: 1
pypi.org: eco2ai

emission tracking library

  • Versions: 22
  • Dependent Packages: 3
  • Dependent Repositories: 1
  • Downloads: 319 Last month
Rankings
Stargazers count: 5.6%
Dependent packages count: 7.3%
Forks count: 9.6%
Average: 13.0%
Downloads: 20.4%
Dependent repos count: 22.1%
Maintainers (1)
Last synced: 6 months ago

Dependencies

poetry.lock pypi
  • apscheduler 3.9.1
  • backports.zoneinfo 0.2.1
  • certifi 2022.6.15
  • charset-normalizer 2.1.0
  • funcsigs 1.0.2
  • futures 3.3.0
  • idna 3.3
  • importlib-resources 5.4.0
  • numpy 1.21.6
  • numpy 1.23.1
  • pandas 1.3.5
  • pandas 1.4.3
  • psutil 5.9.1
  • py-cpuinfo 8.0.0
  • pynvml 11.4.1
  • python-dateutil 2.8.2
  • pytz 2022.1
  • pytz-deprecation-shim 0.1.0.post0
  • requests 2.28.1
  • six 1.16.0
  • tornado 6.2
  • tzdata 2022.1
  • tzlocal 4.2
  • urllib3 1.26.10
  • zipp 3.6.0
pyproject.toml pypi
  • APScheduler --- - !ruby/hash:ActiveSupport::HashWithIndifferentAccess version: "*" python: ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4"
  • pandas --- - !ruby/hash:ActiveSupport::HashWithIndifferentAccess version: ">=1.2.1,<=1.3.5" python: ">=3.7.1, <3.8" - !ruby/hash:ActiveSupport::HashWithIndifferentAccess version: ">=1.4.0,<=1.4.3" python: ">=3.8"
  • psutil ^5.9.1
  • py-cpuinfo --- - !ruby/hash:ActiveSupport::HashWithIndifferentAccess version: "*" python: ">=3.7"
  • pynvml --- - !ruby/hash:ActiveSupport::HashWithIndifferentAccess version: "*" python: ">=3.6"
  • python *
  • requests --- - !ruby/hash:ActiveSupport::HashWithIndifferentAccess version: "*" python: ">=3.7, <4"
  • tornado --- - !ruby/hash:ActiveSupport::HashWithIndifferentAccess version: "*" python: ">=3.7"
  • tzlocal --- - !ruby/hash:ActiveSupport::HashWithIndifferentAccess version: "*" python: ">=3.6"
setup.py pypi