Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Version 3] Add CPU load tracking #316

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

[Version 3] Add CPU load tracking #316

wants to merge 22 commits into from

Conversation

benoit-cty
Copy link
Contributor

@benoit-cty benoit-cty commented Jun 13, 2022

When none of RAPL or PowerGadget is available, the mode will use CPU load to estimate the CPU Power.

How to test:

export CODECARBON_LOG_LEVEL=DEBUG

To check if it's working : CPU load 180 W x 90.9% = 163.62 for whole machine.

If you want to monitor only your process:

export CODECARBON_TRACKING_MODE=process

TODO:

@benoit-cty
Copy link
Contributor Author

Will close #333

@benoit-cty
Copy link
Contributor Author

Here is how to test:

git switch use-cpu-load
codecarbon monitor

If you have RAPL, the log will display a comparison between RAPL and the new estimation based on CPU load:

------------------------
[codecarbon INFO @ 19:09:11] Energy consumed for RAM : 0.000312 kWh. RAM Power : 11.692474365234375 W
[codecarbon DEBUG @ 19:09:11] Done measure for RAM - measurement time: 0.0005 s - last call 6.13 s
[codecarbon INFO @ 19:09:11] Energy consumed for all GPUs : 0.000959 kWh. Total GPU Power : 19.64000343421216 W
[codecarbon DEBUG @ 19:09:11] Done measure for GPU - measurement time: 0.0031 s - last call 6.13 s
[codecarbon DEBUG @ 19:09:11] RAPLFile(name='Processor Energy Delta_0(kWh)', path='/sys/class/powercap/intel-rapl/intel-rapl:1/energy_uj', max_path='/sys/class/powercap/intel-rapl/intel-rapl:1/max_energy_range_uj', energy_delta=Energy(kWh=0.00012791769844518533), power=Power(kW=0.0750830161810631), last_energy=Energy(kWh=0.015906780571247607), max_energy_reading=Energy(kWh=0.018203517614746884))
[codecarbon DEBUG @ 19:09:11] RAPLFile(name='Processor Energy Delta_1(kWh)', path='/sys/class/powercap/intel-rapl/intel-rapl:0/energy_uj', max_path='/sys/class/powercap/intel-rapl/intel-rapl:0/max_energy_range_uj', energy_delta=Energy(kWh=0.00012790536065753963), power=Power(kW=0.07507577435041182), last_energy=Energy(kWh=0.015906798529039753), max_energy_reading=Energy(kWh=0.018203517614746884))
[codecarbon DEBUG @ 19:09:11] get_cpu_details {'Processor Energy Delta_0(kWh)': 0.00012791769844518533, 'Processor Power Delta_0(kWh)': 75.0830161810631, 'Processor Energy Delta_1(kWh)': 0.00012790536065753963, 'Processor Power Delta_1(kWh)': 75.07577435041182}
[codecarbon DEBUG @ 19:09:11] get_static_cpu_details {'Processor Energy Delta_0(kWh)': 0.00012791769844518533, 'Processor Power Delta_0(kWh)': 75.0830161810631, 'Processor Energy Delta_1(kWh)': 0.00012790536065753963, 'Processor Power Delta_1(kWh)': 75.07577435041182}
[codecarbon DEBUG @ 19:09:11] _get_power_from_cpus - DONT MATCH Processor Energy Delta_0(kWh) : 0.00012791769844518533
[codecarbon DEBUG @ 19:09:11] _get_power_from_cpus - MATCH Processor Power Delta_0(kWh) : 75.0830161810631
[codecarbon DEBUG @ 19:09:11] _get_power_from_cpus - DONT MATCH Processor Energy Delta_1(kWh) : 0.00012790536065753963
[codecarbon DEBUG @ 19:09:11] _get_power_from_cpus - MATCH Processor Power Delta_1(kWh) : 75.07577435041182
[codecarbon INFO @ 19:09:11] Delta energy consumed for CPU with intel_rapl : 0.000256 kWh, power : 150.15879053147492 W
[codecarbon INFO @ 19:09:11] Energy consumed for All CPU : 0.004449 kWh
[codecarbon DEBUG @ 19:09:11] Done measure for CPU - measurement time: 0.0010 s - last call 6.13 s
[codecarbon DEBUG @ 19:09:11] CPU load 180 W x 4.2% = 18.0 for whole machine.
[codecarbon INFO @ 19:09:11] Delta energy consumed for CPU with cpu_load : 0.000031 kWh, power : 18.000000000000004 W
[codecarbon INFO @ 19:09:11] Energy consumed for All CPU : 0.004480 kWh
[codecarbon DEBUG @ 19:09:11] Done measure for CPU - measurement time: 0.0019 s - last call 6.13 s
[codecarbon INFO @ 19:09:11] 0.005751 kWh of electricity used since the beginning.
[codecarbon DEBUG @ 19:09:11] last_duration=6.129475831985474
------------------------

@@ -303,10 +303,7 @@ def __init__(
hardware = CPU.from_utils(self._output_dir, "intel_rapl")
self._hardware.append(hardware)
self._conf["cpu_model"] = hardware.get_model()
else:
Copy link
Contributor

@inimaz inimaz Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I arrived to this case. (Testing with Windows machine, but unfortunately I do not have RAPL in this machine and the Intel Power Gadget is not even installed, see #457).
Why remove this else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for testing both mode.

@benoit-cty benoit-cty linked an issue Apr 5, 2024 that may be closed by this pull request
@RafiullahOmar
Copy link
Contributor

RafiullahOmar commented Apr 7, 2024

Is the "Test under Linux with RAPL" done? @benoit-cty

@benoit-cty
Copy link
Contributor Author

Is the "Test under Linux with RAPL" done? @benoit-cty

Yes, it's the only one that works for sure.

@benoit-cty benoit-cty changed the title Add CPU load tracking [Version 3] Add CPU load tracking Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants