mlco2 / codecarbon

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

Regarding the final result of energy consumption calculation #494

Closed qxpBlog closed 5 months ago

qxpBlog commented 5 months ago

@dsblank @Lothiraldan @ndevenish @mp15 @guylifshitz if i use the following way to record my energy consumption :

tracker.start()
start_time = time.time()
ppl = llama_eval(model, test_loader, device)
end_time = time.time()
tracker.stop()

During operation, There are two places that output energy_ Suggestion: one is on the command line:

[codecarbon INFO @ 14:57:11] Energy consumed for RAM : 0.002054 kWh. RAM Power : 46.99779653549194 W
[codecarbon DEBUG @ 14:57:11] RAM : 47.00 W during 7.40 s [measurement time: 0.0005]
[codecarbon INFO @ 14:57:11] Energy consumed for all GPUs : 0.020180 kWh. Total GPU Power : 471.3557745071085 W
[codecarbon DEBUG @ 14:57:11] GPU : 471.36 W during 7.40 s [measurement time: 0.3941]
[codecarbon INFO @ 14:57:11] Energy consumed for all CPUs : 0.001864 kWh. Total CPU Power : 42.5 W
[codecarbon DEBUG @ 14:57:11] CPU : 42.50 W during 7.80 s [measurement time: 0.0001]
[codecarbon INFO @ 14:57:11] 0.024098 kWh of electricity used since the beginning.
[codecarbon DEBUG @ 14:57:11] last_duration=7.402188777923584
------------------------
[codecarbon DEBUG @ 14:57:11] We apply an energy mix of 544 g.CO2eq/kWh for China
[codecarbon DEBUG @ 14:57:11] EmissionsData(timestamp='2024-01-25T14:57:11', project_name='codecarbon', run_id='0a42768f-7357-4899-a9c6-201193dd2df1', duration=157.90563035011292, emissions=0.013118096917863411, emissions_rate=8.307554891347186e-05, cpu_power=42.5, gpu_power=471.3557745071085, ram_power=46.99779653549194, cpu_energy=0.0018641464490029552, gpu_energy=0.020179937255048408, ram_energy=0.002054339049231724, energy_consumed=0.02409842275328308, country_name='China', country_iso_code='CHN', region='', cloud_provider='', cloud_region='', os='Linux-5.15.0-91-generic-x86_64-with-glibc2.35', python_version='3.10.13', codecarbon_version='2.3.2', cpu_count=112, cpu_model='Intel(R) Xeon(R) Gold 6330 CPU @ 2.00GHz', gpu_count=4, gpu_model='4 x NVIDIA A40', longitude=113.722, latitude=34.7732, ram_total_size=125.32745742797852, tracking_mode='machine', on_cloud='N', pue=1.0)
[codecarbon DEBUG @ 14:57:11] We apply an energy mix of 544 g.CO2eq/kWh for China
[codecarbon DEBUG @ 14:57:11] EmissionsData(timestamp='2024-01-25T14:57:11', project_name='codecarbon', run_id='0a42768f-7357-4899-a9c6-201193dd2df1', duration=37.83032846450806, emissions=0.0031401651014669844, emissions_rate=8.300655132859997e-05, cpu_power=42.5, gpu_power=471.3557745071085, ram_power=46.99779653549194, cpu_energy=0.00044629870156447115, gpu_energy=0.00483430331188317, ram_energy=0.0004879958711441904, energy_consumed=0.005768597884591827, country_name='China', country_iso_code='CHN', region='', cloud_provider='', cloud_region='', os='Linux-5.15.0-91-generic-x86_64-with-glibc2.35', python_version='3.10.13', codecarbon_version='2.3.2', cpu_count=112, cpu_model='Intel(R) Xeon(R) Gold 6330 CPU @ 2.00GHz', gpu_count=4, gpu_model='4 x NVIDIA A40', longitude=113.722, latitude=34.7732, ram_total_size=125.32745742797852, tracking_mode='machine', on_cloud='N', pue=1.0)
[codecarbon DEBUG @ 14:57:13] ApiClient - Successful upload emission {'timestamp': '2024-01-25T14:57:11.858266+00:00', 'run_id': '0a42768f-7357-4899-a9c6-201193dd2df1', 'duration': 37, 'emissions_sum': 0.0031401651014669844, 'emissions_rate': 8.300655132859997e-05, 'cpu_power': 42.5, 'gpu_power': 471.3557745071085, 'ram_power': 46.99779653549194, 'cpu_energy': 0.00044629870156447115, 'gpu_energy': 0.00483430331188317, 'ram_energy': 0.0004879958711441904, 'energy_consumed': 0.005768597884591827} to https://api.codecarbon.io/emission

Another one in the output file emissions.csv:

2024-01-25T14:57:11,codecarbon,0a42768f-7357-4899-a9c6-201193dd2df1,157.90563035011292,0.0131180969178634,8.307554891347186e-05,42.5,471.3557745071085,46.99779653549194,0.0018641464490029,0.0201799372550484,0.0020543390492317,0.024098422753283,China,CHN,,,,Linux-5.15.0-91-generic-x86_64-with-glibc2.35,3.10.13,2.3.2,112.0,Intel(R) Xeon(R) Gold 6330 CPU @ 2.00GHz,4.0,4 x NVIDIA A40,113.722,34.7732,125.32745742797852,machine,N,1.0

I want to know which is the final result of energy consumption?

LuisBlanche commented 5 months ago

Hi, first of all it seems that you are sending results to the API (see doc about API here , please note that this data is sent to a public database that is used for the public dashboard. I can see from you stacktrace that you are using a project named codecabon but I do not know in which organisation this project is. If you know the organisation you're using you can check your results in the dashboard. If you don't know which organisation you used , the only way to handle Organization / Team / Projects for now is through OpenAPI doc, we're currently updating the python API Client so you can have CLI commands to do so.

On to your question now, the results in your emissions.csv file should be the same as those sent to the API , do you notice any differences ?

qxpBlog commented 5 months ago

Hi, first of all it seems that you are sending results to the API (see doc about API here , please note that this data is sent to a public database that is used for the public dashboard. I can see from you stacktrace that you are using a project named codecabon but I do not know in which organisation this project is. If you know the organisation you're using you can check your results in the dashboard. If you don't know which organisation you used , the only way to handle Organization / Team / Projects for now is through OpenAPI doc, we're currently updating the python API Client so you can have CLI commands to do so.

On to your question now, the results in your emissions.csv file should be the same as those sent to the API , do you notice any differences ?

only have a little differences, now i think that it has no effect, Thanks