CodeCarbon
Purpose:: Estimate CO2 emissions of Python applications
Website:: https://codecarbon.io/
Docs:: https://mlco2.github.io/codecarbon/
Source Code:: https://github.com/mlco2/codecarbon
Description
CodeCarbon is a lightweight software package that seamlessly integrates into your Python codebase. It estimates the amount of carbon dioxide (CO2) produced by the cloud or personal computing resources used to execute the code.
Research paper
Lottick, K., Susai, S., Friedler, S. A., & Wilson, J. P. (2019). Energy Usage Reports: Environmental awareness as part of algorithmic accountability. https://doi.org/10.48550/arXiv.1911.08354
Blog post about the paper: AI Computing Emits CO₂. We Started Measuring How Much (by Kamal Goyal) | Medium
Methodology
Methodology — CodeCarbon 2.0.0 documentation
- CPU (Intel): RAPL
- GPU (Nvidia): System Management Interface (smi) →
pynvml
library - RAM: static value (rough estimation)
Usage
from codecarbon import EmissionsTracker
tracker = EmissionsTracker()
tracker.start()
# GPU Intensive code goes here
tracker.stop()