Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sudoless power metrics on Apple Silicon #731

Open
hturner opened this issue Dec 9, 2024 · 7 comments · May be fixed by #752
Open

Sudoless power metrics on Apple Silicon #731

hturner opened this issue Dec 9, 2024 · 7 comments · May be fixed by #752
Assignees
Labels
enhancement New feature or request

Comments

@hturner
Copy link

hturner commented Dec 9, 2024

Since #464 was closed, there is a new option for obtaining power metrics on Apple Silicon chips that does not require sudo: https://github.com/vladkens/macmon by @vladkens.

I am not affiliated with the project, but found it after discovering that codecarbon currently requires sudo privileges on macOS for full functionality (as documented in the CPU section of the docs on power usage). This limits its use on managed computers, e.g. in a university setting.

macmon appears to be actively maintained and also has an MIT license, so a promising tool to build on. Hopefully someone will be able to look into this further.

@benoit-cty
Copy link
Contributor

Thanks to let us know about it !
What do you think of it @LuisBlanche ?

@benoit-cty benoit-cty added the enhancement New feature or request label Dec 11, 2024
@vladkens
Copy link

Hi, if you want to adapt macmon into your project, I think I can split the metrics collection part into the library. I've seen that some projects are now copying the metrics collection code, but Apple continuously changing their APIs on new chips, so the copied code become irrelevant.

@LuisBlanche
Copy link
Contributor

I think it's great ! I didn't find this tool when I first implemented the Powermetrics feature. I am currently refactoring the Powermetrics code to add better RAM support so now might be a good time to check this out

@LuisBlanche
Copy link
Contributor

Hi @vladkens I see you're the creator of macmon. We are not going to copy the code rather use your library, that way we can rely on you maintaining it working :)
I have a question though, we're currently investigating how to improve RAM consumption and I don't see "RAM power" in macmon metrics whereas it is availalable in Powermetrics. Is there any technical limitation for this ? If no is this something you'd be encline to add ?

@LuisBlanche LuisBlanche self-assigned this Dec 14, 2024
@vladkens
Copy link

@LuisBlanche

Hi. There are no technical limitations, I just need to check which keys can provide this information. Most likely, there shouldn't be any issues with this.

I also have a few questions regarding the library. I am currently thinking about how to make macmon work as both a library and a CLI tool simultaneously.

I’m curious about which APIs you would like to have. Right now, I essentially have one "public" function: get_metrics, which returns compiled estimated metrics for a certain sample time. Is that enough for you, or would you need more granular methods?

Also, as I understant, codecarbon is a Python application, so you would also need Python bindings?

@LuisBlanche
Copy link
Contributor

Most of the estimation apps we use don't have python binding, we run them as CLI tools using subprocess. I actually have already started a branch to check if I can replace Powermetrics with macmon and it seems to work ok using macmon raw command and reading and averaging power measures from the json file. Only thing is missing is power for RAM. A useful feature could also be to say how many points of data you want to collect so that the process is stopped after that avoiding the need to implement this on our side

@vladkens
Copy link

vladkens commented Dec 17, 2024

@LuisBlanche, If you use subprocess, it's much easier 😄. I added the ability to choose the sample count and include RAM power to output (also added GPU RAM power, but only after I did release I remembered that Mac uses unified memory, so I'm not sure what this parameter actually means).

Available from version v0.4.2. Also, added docs for output data.

macmon pipe -s 10 -i 500 | jq

Note: raw command is alias to pipe now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants