mlco2 / codecarbon

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

how use from CLI to measure energy consumed during run of a given command #382

Open mkbane opened 1 year ago

mkbane commented 1 year ago

Description

I wish to use codecarbon to give me the energy consumed by my CPU for running a command eg "a.out", so wanted to do something like

codecarbon ./a.out

and get a figure e.g. of Joules of kWh.

How do I do this? I cannot see it within the documentation

benoit-cty commented 1 year ago

Hello, We do not support this. What you can do is run codecarbon monitorthen run a.outin another terminal. Then manually stop codecarbon with Ctrl + C when you program end. Sorry not very handy !

Or you could write a Python script that run a.out and use the codecarbon tracker in the script.

jennydaman commented 12 months ago

@benoit-cty would you accept a PR for this? I think we should implement a command codecarbon monitor [COMMAND...] where: