from codecarbon import EmissionsTracker
from time import sleep
import timeit
= EmissionsTracker()
tracker tracker.start()
[codecarbon INFO @ 21:05:21] [setup] RAM Tracking...
[codecarbon INFO @ 21:05:21] [setup] GPU Tracking...
[codecarbon INFO @ 21:05:21] No GPU found.
[codecarbon INFO @ 21:05:21] [setup] CPU Tracking...
[codecarbon ERROR @ 21:05:21] Unable to read Intel RAPL files for CPU power, we will use a constant for your CPU power. Please view https://github.com/mlco2/codecarbon/issues/244 for workarounds : [Errno 13] Permission denied: '/sys/class/powercap/intel-rapl/intel-rapl:0/energy_uj'
[codecarbon INFO @ 21:05:21] Tracking Intel CPU via RAPL interface
[codecarbon ERROR @ 21:05:23] Unable to read Intel RAPL files for CPU power, we will use a constant for your CPU power. Please view https://github.com/mlco2/codecarbon/issues/244 for workarounds : [Errno 13] Permission denied: '/sys/class/powercap/intel-rapl/intel-rapl:0/energy_uj'
[codecarbon INFO @ 21:05:23] >>> Tracker's metadata:
[codecarbon INFO @ 21:05:23] Platform system: Linux-5.15.35-2-pve-x86_64-with-glibc2.31
[codecarbon INFO @ 21:05:23] Python version: 3.9.5
[codecarbon INFO @ 21:05:23] Available RAM : 29.297 GB
[codecarbon INFO @ 21:05:23] CPU count: 6
[codecarbon INFO @ 21:05:23] CPU model: Intel(R) Xeon(R) CPU E3-1240 v6 @ 3.70GHz
[codecarbon INFO @ 21:05:23] GPU count: None
[codecarbon INFO @ 21:05:23] GPU model: None
= timeit.timeit(stmt='[random.randint(0, 1000) for r in range(10000)]',
t1 ='import random',
setup=1000
number )
= tracker.stop()
emissions print(f"Emission of the run {emissions} in XXX unit")
tracker.final_emissions_data
[codecarbon INFO @ 21:05:35] Energy consumed for RAM : 0.000030 kWh. RAM Power : 10.986328125 W
[codecarbon INFO @ 21:05:35] Energy consumed for all CPUs : 0.000000 kWh. All CPUs Power : 0.0 W
[codecarbon INFO @ 21:05:35] 0.000030 kWh of electricity used since the begining.
Emission of the run 1.6380519336962607e-06 in XXX unit
EmissionsData(timestamp='2023-02-10T21:05:35', project_name='codecarbon', run_id='792a34ed-7782-4232-a7f1-299f04da5e6e', duration=9.76309871673584, emissions=1.6380519336962607e-06, emissions_rate=0.0001677799212342617, cpu_power=0.0, gpu_power=0.0, ram_power=10.986328125, cpu_energy=0, gpu_energy=0, ram_energy=2.9782762430841105e-05, energy_consumed=2.9782762430841105e-05, country_name='France', country_iso_code='FRA', region='île-de-france', cloud_provider='', cloud_region='', os='Linux-5.15.35-2-pve-x86_64-with-glibc2.31', python_version='3.9.5', cpu_count=6, cpu_model='Intel(R) Xeon(R) CPU E3-1240 v6 @ 3.70GHz', gpu_count=None, gpu_model=None, longitude=2.4075, latitude=48.8323, ram_total_size=29.296875, tracking_mode='machine', on_cloud='N')
10) sleep(
= tracker.stop()
emissions print(f"Emission of the run {emissions} in XXX unit")
tracker.final_emissions_data
[codecarbon INFO @ 21:05:46] Energy consumed for RAM : 0.000060 kWh. RAM Power : 10.986328125 W
[codecarbon INFO @ 21:05:46] Energy consumed for all CPUs : 0.000000 kWh. All CPUs Power : 0.0 W
[codecarbon INFO @ 21:05:46] 0.000060 kWh of electricity used since the begining.
Emission of the run 3.322356042190222e-06 in XXX unit
EmissionsData(timestamp='2023-02-10T21:05:46', project_name='codecarbon', run_id='792a34ed-7782-4232-a7f1-299f04da5e6e', duration=19.801576852798462, emissions=3.322356042190222e-06, emissions_rate=0.00016778239767913683, cpu_power=0.0, gpu_power=0.0, ram_power=10.986328125, cpu_energy=0, gpu_energy=0, ram_energy=6.0406473494367674e-05, energy_consumed=6.0406473494367674e-05, country_name='France', country_iso_code='FRA', region='île-de-france', cloud_provider='', cloud_region='', os='Linux-5.15.35-2-pve-x86_64-with-glibc2.31', python_version='3.9.5', cpu_count=6, cpu_model='Intel(R) Xeon(R) CPU E3-1240 v6 @ 3.70GHz', gpu_count=None, gpu_model=None, longitude=2.4075, latitude=48.8323, ram_total_size=29.296875, tracking_mode='machine', on_cloud='N')