mlco2 / codecarbon

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

How works CPU constant mode (when RAPL files are not found) ? #477

Open Sarah7223 opened 7 months ago

Sarah7223 commented 7 months ago

Hello !

I am trying to use CodeCarbon on a Linux virtual machine. I don't have the RAPL module on it so the cpu tracking falls on constant mode. If I understood well the methodology, in this case the cpu energy consumption = TDP * usage (constante=0,5) ? If it's true, experimentally, the cpu_energy divided by the duration should be constant between different measures on the same machine. In practice, I made several measures on the same machine which are saved on a .csv, and then I calculated cpu_ernergy/duration on all the lines, I get close values but not equal, do you know why ?

I saw that you began to work on CPU load tracking with psutil, it is not merged yet, right ? Do you know if it is possible to custom the kernel of a virtual machine so it is able to use RAPL files or it doesn't work on virtual environnements ?

Thank you for your help !

benoit-cty commented 7 months ago

Sorry, I dont think it could work with Virtual Machine. With containers, like Docker, you could allow the host to share system files with the host.

Yes the CPU load is coming and you could try the code of the branch if you want, it's already supposed to work.

RafiullahOmar commented 2 months ago

@benoit-cty When we get "No CPU tracking mode found. Falling back on CPU constant mode." message. Do we get the accurate energy consumption data with CPU constant mode?

benoit-cty commented 2 months ago

It's a constant and do not consider the CPU usage, so it is not accurate.

RafiullahOmar commented 2 months ago

@benoit-cty I believe that since the 'Test under Linux with RAPL' has been done in #316, so even if we encounter the warning 'No CPU tracking mode found. Falling back on CPU constant mode,' we will still obtain accurate results. am I right?

benoit-cty commented 2 months ago

Yes the goal of this PR is to use the CPU load in real time and multiply it to the TDP.