mlco2 / codecarbon

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

Add data for Apple M1 variants to cpu_power.csv #294

Closed maxkahan closed 4 months ago

maxkahan commented 2 years ago

Description

The current version of data/hardware/cpu_power.csv contains only data for the base Apple M1 chip. Now new variants are in circulation - the M1 Pro and the M1 Max - and the M1 Ultra was announced last month.

The M1 Pro and M1 Max supposedly have a peak CPU power consumption of 30W, according to this article, and the M1 Ultra supposedly has a CPU TDP of 60W as it's 2 M1 Max chips coupled together, though Apple haven't been fully transparent.

Should these values be added in?

benoit-cty commented 2 years ago

Thanks, I will be happy to add them, could you tell me the exact string reported by cpuinfo for these CPU ?

maxkahan commented 2 years ago

Ah, unfortunately I don't have access to machines with these chips. I use a regular M1 chipped Mac, for which you already have data. I'm hoping to raise awareness of the tool in the software dev community where Macbooks are relatively common - so when these chips start becoming the 'default' for Mac users, this tool has the data for them!

benoit-cty commented 2 years ago

cpu_power.csv is used as a fallback to give an estimation based on 50% of the CPU TDP : it is very bad.

A better way will be to find an API to get the real power consumption. Maybe powermetrics : https://github.com/singhkays/apple-m1-power-consumption-powermetrics/blob/main/autorun-local-videos.py.

MyGodItsFull0fStars commented 1 year ago

If help is still needed, I can trace the power consumption of my MacBook M1 Max if that is what is required.

benoit-cty commented 1 year ago

Hello @MyGodItsFull0fStars, Yes, help is needed, what do you see in the CodeCarbon log ?

MyGodItsFull0fStars commented 1 year ago

Okay great! I am glad to help. But I am new to the project so could you help me out in properly tracking the consumption?

I installed codecarbon with Python 3.10 so far. Is there a specific executable I should use, like the powermetrics above?

benoit-cty commented 1 year ago

The first step is to report the output of this Python script:

from codecarbon import EmissionsTracker
import time
tracker = EmissionsTracker()
tracker.start()
time.sleep(20)
tracker.stop()
print(tracker.final_emissions_data)

So we could see what append without development.

Then it will depend of what you contribution you are ready to do :

MyGodItsFull0fStars commented 1 year ago

Thank you for providing the code snippet! I will do the emission tracking as soon as possible. Plus I will look into the other contribution items you have listed.

MyGodItsFull0fStars commented 1 year ago

@benoit-cty Below is the output of the Python script you have provided:

EmissionsData(timestamp='2023-04-17T09:50:27', project_name='codecarbon', run_id='f1b12836-18ba-40c4-86ba-07d6b51734ef', duration=20.007510900497437, emissions=7.841141743726203e-06, emissions_rate=0.0003919099073703992, cpu_power=5.0, gpu_power=0.0, ram_power=12.0, cpu_energy=2.778735789987776e-05, gpu_energy=0, ram_energy=6.668422937393189e-05, energy_consumed=9.447158727380966e-05, country_name='Austria', country_iso_code='AUT', region='carinthia', cloud_provider='', cloud_region='', os='macOS-12.6.2-arm64-arm-64bit', python_version='3.10.0', cpu_count=10, cpu_model='Apple M1 Max', gpu_count=None, gpu_model=None, longitude=14.2999, latitude=46.6233, ram_total_size=32.0, tracking_mode='machine', on_cloud='N')

MyGodItsFull0fStars commented 1 year ago

Regarding the TDP, Apple did not publish this value but in the source notebookcheck they claim that it is 35 W TDP.

The source anandtech claims that the TDP does not exist for this chip series.

Therefore, I will wait with adding the value to the CSV until it is approved to do so.

LuisBlanche commented 1 year ago

See #464

SaboniAmine commented 4 months ago

Closing this as the PR to achieve the measurement have been merged. Please re-open if there is any question left.