mlco2 / codecarbon

Track emissions from Compute and recommend ways to reduce their impact on the environment.
https://mlco2.github.io/codecarbon
MIT License
1.18k stars 178 forks source link

Intel Xeon CPUs energy consumption #515

Closed RafiullahOmar closed 6 months ago

RafiullahOmar commented 8 months ago

Description

I couldn't find any information in the documentation about whether CodeCarbon can measure energy consumption for Intel Xeon CPUs with Ubuntu 22.04 OS. Does CodeCarbon measure its energy consumption? And, is getting the same values for RAM and CPU repeatedly after each 10 secs a normal behavior? for example getting 5.904338836669922 W for RAM and 42.5 W for CPU repeatedly as below: [codecarbon INFO @ 18:28:46] Energy consumed for RAM : 0.000173 kWh. RAM Power : 5.904338836669922 W [codecarbon INFO @ 18:28:46] Energy consumed for all CPUs : 0.001248 kWh. All CPUs Power : 42.5 W The details of processor is: Processor: 11th Gen Intel(R) Core(TM) i7-11370H @ 3.30GHz, 2995 Mhz, 4 Core(s), 8 Logical Processor(s) CodeCarbon version: 2.1.4 Python version: 3.10.11 Operating System: Windows 11

benoit-cty commented 8 months ago

Hello, constant value for RAM is normal, but I think you are also in "constant mode" for CPU, did you allow users to read RAPL files ? Look at https://github.com/mlco2/codecarbon/issues/244#issue-987101271 for the way to do it.

RafiullahOmar commented 8 months ago

Thanks, @benoit-cty. Actually, for the second part of the question regarding obtaining a constant value, the operating system is not Linux; it is Windows 11.

benoit-cty commented 8 months ago

For Windows you have to install "Intel Power Gadget". But Intel deprecate it and switch to https://github.com/intel/pcm , which we do not support.

RafiullahOmar commented 8 months ago

Does CodeCarbon support PCM? #457 Also, since issue #316 is still open, has the testing process been completed for Windows?

benoit-cty commented 8 months ago

Sorry, the answer is no for both questions. They are in top priority but we have not enough volunteer.

RafiullahOmar commented 8 months ago

Thanks, @benoit-cty. Could I have your opinion on whether CodeCarbon can measure the energy consumption of Intel Xeon CPUs running Ubuntu 22.04 OS? Does CodeCarbon have the capability to measure their energy consumption? As I could not find anything specific to Intel Xeon CPUs.

benoit-cty commented 8 months ago

Yes, it work on all CPUs as soon as you allow the reading of RAPL files : https://github.com/mlco2/codecarbon/issues/244#issue-987101271

RafiullahOmar commented 8 months ago

@benoit-cty, Sometimes I get this message: [codecarbon WARNING @ 03:54:28] We saw that you have a Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz but we don't know it. Please contact us.

benoit-cty commented 8 months ago

I'va added it to the list : https://github.com/mlco2/codecarbon/pull/526

RafiullahOmar commented 7 months ago

@benoit-cty did anyone added the CPU to the list as I still get the same warning?

benoit-cty commented 7 months ago

Yes, but we still have to publish a new version and then you could update your local version of codecarbon.

RafiullahOmar commented 7 months ago

@benoit-cty Thanks! Could you please let me know when the closest possible date for publishing could be? I'm currently running some experiments on the mentioned CPU.

benoit-cty commented 7 months ago

Hello, the version has been published : https://pypi.org/project/codecarbon/2.3.5/

`pip install -U codecarbon' to update your env.

RafiullahOmar commented 7 months ago

Thank you, @benoit-cty . Even after updating to version 2.3.5, CodeCarbon still displays the following warnings: [codecarbon INFO @ 10:27:38] [setup] CPU Tracking... [codecarbon WARNING @ 10:27:38] No CPU tracking mode found. Falling back on CPU constant mode. [codecarbon WARNING @ 10:27:40] We saw that you have a Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz but we don't know it. Please contact us.

benoit-cty commented 7 months ago

Oh, I see, I've added the i7-11370H from your first message, not the Silver 4208. Did you know how to submit a PR ? Or could you find the TDP ?

RafiullahOmar commented 7 months ago

@benoit-cty , the TDP is 85W for Silver 4208, and the default value is also 85 in codecarbon. Therefore, I believe that I will give an accurate result without specifying the CPU(?). Nevertheless, I have also created a PR for adding Silver 4208 cpu.

RafiullahOmar commented 7 months ago

Hi @benoit-cty @inimaz ,

I'd like to get your opinion on whether I'm correct or not before proceeding with my experiments:

I've received the following warnings:

[codecarbon WARNING @ 18:42:17] No CPU tracking mode found. Falling back on CPU constant mode.
[codecarbon WARNING @ 18:42:19] We detected that you have an Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz, but we don't have it in our database. Please contact us.

I have a question and two opinions that I'd like your feedback on:

Question: Despite confirming that RAPL is available, why am I still receiving this warning?

Opinions:

  1. As in issue #316, the "Test under Linux with RAPL" was conducted, indicating that even if RAPL is not accessible, the CPU constant mode will provide accurate results.
  2. Regarding the second warning, since the TDP is 85, even if the specific CPU is unknown, it should still provide accurate results because the default TDP in CodeCarbon is 85.
  3. Therefore, despite receiving the above warnings, I believe I will still obtain accurate results. Let me know your thoughts.
benoit-cty commented 7 months ago

Hi, Yes, if you use #316 it will be accurate. Let me know if it works.

RafiullahOmar commented 6 months ago

Hi @benoit-cty , I saw that a new version of codecarbon has been published. I assumed that it might have solved the problem of not recognizing the CPU and other warnings related to constant mode. However, when I upgrade its version and tested it, I received the same warning again as: [codecarbon WARNING @ 17:22:49] No CPU tracking mode found. Falling back on CPU constant mode. [codecarbon WARNING @ 17:22:50] We saw that you have a Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz but we don't know it. Please contact us.

benoit-cty commented 6 months ago

Hello, unfortunatly, your CPU is not in the updated list : https://github.com/mlco2/codecarbon/blob/master/codecarbon/data/hardware/cpu_power.csv

RafiullahOmar commented 6 months ago

I added it, but I don't know why it's not in the updated list. I remember the pull request being approved as well.

benoit-cty commented 6 months ago

Oh, yes indeed it is in the list : https://github.com/mlco2/codecarbon/blob/master/codecarbon/data/hardware/cpu_power.csv#L3769

So you may fall under the bug https://github.com/mlco2/codecarbon/pull/551 that was fixed but not yet published on pypi, I will do it this week-end.

RafiullahOmar commented 6 months ago

You're right. What do you think about below warning: [codecarbon WARNING @ 17:22:49] No CPU tracking mode found. Falling back on CPU constant mode. I verified that RAPL is accessible on the system, but CodeCarbon seems to be unable to access it. I run the part of the code responsible for RAPL access within CodeCarbon itself, but it couldn't access it.

benoit-cty commented 6 months ago

Hello, could you try to update codecarbon ? The new version 2.4.2 will support your CPU.

benoit-cty commented 6 months ago

For RAPL can you share the log in debug mode ? And what say ls -l /sys/class/powercap/intel-rapl/intel-rapl:1/energy_uj and cat /sys/class/powercap/intel-rapl/intel-rapl:1/energy_uj ?

RafiullahOmar commented 6 months ago

Thanks, Now it recognized the CPU.

  1. ls -l /sys/class/powercap/intel-rapl/intel-rapl:1/energy_uj says: -r-------- 1 root root 4096 Apr 11 19:39 /sys/class/powercap/intel-rapl/intel-rapl:1/energy_uj
benoit-cty commented 6 months ago

Thanks, only root can read your RAPL files, you have to do : sudo chmod -R a+r /sys/class/powercap/intel-rapl

Or look at https://github.com/mlco2/codecarbon/issues/244 for a permanent way to do it.

RafiullahOmar commented 6 months ago

Thanks, @benoit-cty! resolved both issues. I'm currently receiving a warning message that isn't critical right now, but addressing it would improve CodeCarbon. [codecarbon WARNING @ 10:15:02] Invalid gpu_ids format. Expected a string or a list of ints.

inimaz commented 6 months ago

Perfect @RafiullahOmar, I have created a separate issue to investigate that warning, thanks for telling us! You can see its state here #557

benoit-cty commented 6 months ago

Closing this issue as we have already solved many issues in it.