lfwa / carbontracker

Track and predict the energy consumption and carbon footprint of training deep learning models.
MIT License
352 stars 26 forks source link

Joules/s cannot be directly converted to KwH #42

Closed Hasseneby closed 3 years ago

Hasseneby commented 3 years ago

Hi Everyone, I have noticed that in your function energy_usage() the conversion (line 100 to line 103), the energy_usage vairable is expressed into Joules/s energy_usage = np.multiply(avg_power_usage, time).sum() If energy_usage value is expressed into Joule/s then we cannot convert this value to Kwh using the constant 3600000. In fact the value Joule would corespond to Kilowatt and not Kilowatt hours. line 103 energy_usage /= 3600000 KW This conversion make an overestimation to the final result compared to the RAPL measures. Can you please check this issue and tell me if you understand what i meant ? In the case i am right, can you please modify the conversion ?

Please find a screenshot of the issue below.

issue

lfwa commented 3 years ago

Hi Hasseneby,

Thanks for your feedback and taking time to look through the code base!

I am not sure that I agree. avg_power_usage in line 99 should store the average power usage for the epoch measured in watt (= joule per second) by taking the mean of the power usage measurements from the epoch. We then multiply this average by the epoch duration in seconds to get the energy usage in joule (since watt times second is joule) in line 100, where energy_usage = np.multiply(avg_power_usage, time).sum(). The sum()function is simply there to convert from a numpy array to a float. The conversion from joule to kWh can then be done by dividing by 3 600 000 in line 103, since 1 J = 1 W s = 1/1000 kW s = 1/(36001000) kW h.

Hope this helps. Let me know if I missed anything or misunderstood the issue.

lfwa commented 3 years ago

Closing issue due to inactivity. If it has not been resolved, please reopen the issue.