Package: eco2ai
Eco2AIAbout Eco2AI :clipboard:Installation :wrench:Use examples :computer:Important note :blue_book:CitingFeedback :envelope:About Eco2AI :clipboard:The Eco2AI is a python library for CO2emission 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_nameexperiment_descriptionstart_timeduration(s)power_consumption(kWTh)CO2_emissions(kg)CPU_nameGPU_nameOScountryInstallationTo install the eco2AI library, run the following command:pip install eco2aiUse examplesExample usage eco2AIYou can also find eco2AI tutorial on youtubeThe eco2AI interface is quite simple. Here is the simplest usage example:importeco2aitracker=eco2ai.Tracker(project_name="YourProjectName",experiment_description="training the <your model> model")tracker.start()<yourgpu&(or)cpucalculations>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:fromeco2aiimporttrack@trackdeftrain_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:importeco2aitracker=eco2ai.Tracker(project_name="YourProjectName",experiment_description="training <your model> model",file_name="emission.csv")tracker.start()<yourgpu&(or)cpucalculations>tracker.stop()...# now, we want to create a new tracker for new calculationstracker=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()<yourgpu&(or)cpucalculations>tracker.stop()You can also set parameters using the set_params() function, as in the example below:fromeco2aiimportset_params,Trackerset_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()<yourcode>tracker.stop()Important noteIf 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 ReviewFor 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 Eco2AIAn example of using the library is given in thepublication. It the paper we presented experiments of tracking equivalent CO2emissions using eco2AI while trainingruDALL-Emodels with with 1.3 billion (Malevich, ruDALL-E XL 1.3B) and 12 billion parameters (Kandinsky, ruDALL-E XL 12B). These aremultimodalpre-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 theEmojis datasetis given in the table below.ModelTrain timePower, kWhCO2, kgGPUCPUBatch SizeMalevich4h 19m1.370.33A100 Graphics, 1AMD EPYC 7742 64-Core4Kandinsky9h 45m24.505.89A100 Graphics, 8AMD EPYC 7742 64-Core12Also we presented results for training of Malevich with optimized variation ofGELUactivation function. Training of the Malevich with the8-bit version of GELUallows us to spent about 10% less energy and, consequently, produce less equivalent CO2emissions.Citing Eco2AIThe Eco2AI is licensed under aApache licence 2.0.Please consider citing the following paper in any research manuscript using the Eco2AI library:@inproceedings{budennyy2023eco2ai,
  title={Eco2ai: carbon emissions tracking of machine learning models as the first step towards sustainable ai},
  author={Budennyy, SA and Lazarev, VD and Zakharenko, NN and Korovin, AN and Plosskaya, OA and Dimitrov, DV and Akhripkin, VS and Pavlov, IV and Oseledets, IV and Barsola, IS and others},
  booktitle={Doklady Mathematics},
  pages={1--11},
  year={2023},
  organization={Springer}
}In collaboration with