### Install CodeCarbon with pip Source: https://mlco2.github.io/codecarbon Install the CodeCarbon library using pip. This is the first step to start tracking emissions. ```bash pip install codecarbon ``` -------------------------------- ### Track Python code with EmissionsTracker Source: https://mlco2.github.io/codecarbon Use the EmissionsTracker as a context manager to track CO₂ emissions from your Python code. Ensure to start and stop the tracker to get the emissions data. ```python from codecarbon import EmissionsTracker tracker = EmissionsTracker() tracker.start() # Your code here emissions = tracker.stop() print(f"Emissions: {emissions} kg CO₂") ``` -------------------------------- ### Detect hardware with codecarbon CLI Source: https://mlco2.github.io/codecarbon Use the CodeCarbon CLI to detect your hardware configuration for emissions tracking. ```bash codecarbon detect ``` -------------------------------- ### Track any command with codecarbon CLI Source: https://mlco2.github.io/codecarbon Monitor CO₂ emissions for any command using the CodeCarbon CLI. The --no-api flag can be used to disable API calls. ```bash codecarbon monitor --no-api -- python train.py ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.