GithubHelp home page GithubHelp logo

powerapi-ng / pyrapl Goto Github PK

View Code? Open in Web Editor NEW
95.0 95.0 9.0 126 KB

a library to measure the python energy consumption of python code

License: MIT License

Python 100.00%
code energy-consumption measure python

pyrapl's People

Contributors

altor avatar chakib-belgaid avatar iivanoo avatar rouvoy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyrapl's Issues

revert the measure unit back to uJ

in small portion of codes and with the introduction of number we loose a lot of precision when we convert values from uJ to Joules so revert it back

Negative energy_uj measurement

Hello everyone,

I took some measurements today during the inference from a Neural Network model from a two-socket server processor. The server has two AMD sockets and during the measurement I get from one socket high negative energy in microjoules. Joule has unit in Coulomb * Volt. Coulomb is the electrical charge, I suppose if something is wrong with the measured energy in microjoules from the sensor, either has something changed the electrical charge or something else happening.

What would be that in your opinion? A negative charge, a software issue or something else?

Btw the cooling system was not working properly, maybe that contributed to noise and inference from the heat.

Portability

Use pyRAPL on multiple architecture :

  • support for architecture that have psys device

Measurements of multiple functions

Hello,

I am having some trouble getting pyRAPL to work the way I want to, and was hoping someone might be able to help. I have searched for tutorials already with no luck, leading me here.

Currently I am using the Measurement.begin() and Measurement.end() method to gather the power consumption of a specific piece of code. This then gets saved to a .csv file so that the data can be analyzed later on.

What I would like to do is use this method throughout my code to measure the power consumption of multiple functions in order to determine what has the highest power cost and so on. Currently, I set up pyRAPL once, create a .csv output using a specific file, create the instance of pyRAPL.Measurement, begin and end the measurement around the code in question, export the results to the .csv, and finally save the .csv to flush the buffers.

I have tried repeating this method with other functions in the code, however I get this error: TypeError: vars() argument must have dict attribute. The error occurs on line 46 of buffered_output.py. Any advice on how to fix this issue?

Measurements error

I tried to run a simple following example with pyRAPL but something went wrong when measurement ends :

I'm using Fedora 35,
python 3.9.12

Here the code :

import pyRAPL

pyRAPL.setup()

csv_output = pyRAPL.outputs.CSVOutput('results.csv')

@pyRAPL.measureit(output=csv_output)
def test(N):
    a = 0
    for i in range(N):
        a += 1
    return a

test(1000)

csv_output.save()

TypeError                                 Traceback (most recent call last)
~/test_measurement.ipynb Cellule 6 in <cell line: 14>()
     [11]        a += 1
     [12]    return a
---> [14] test(1000)
     [17] csv_output.save()

File ~/.conda/envs/exp_env/lib/python3.9/site-packages/pyRAPL/measurement.py:123, in measureit.<locals>.decorator_measure_energy.<locals>.wrapper_measure(*args, **kwargs)
    121     val = func(*args, **kwargs)
    122 sensor.end()
--> 123 sensor._results = sensor._results / number
    124 sensor.export()
    125 return val

File ~/.conda/envs/exp_env/lib/python3.9/site-packages/pyRAPL/result.py:53, in Result.__truediv__(self, number)
     51 _duration = self.duration / number
     52 _pkg = [j / number for j in self.pkg]
---> 53 _dram = [j / number for j in self.dram]
     54 return Result(self.label, self.timestamp, _duration, _pkg, _dram)

TypeError: 'NoneType' object is not iterable

API proposal

What about providing an API like this:

import pyRAPL

rapl = pyRAPL.PyRAPL()
record = rapl.record(pyRAPL.PKG|pyRAPL.DRAM)
foo()
bar()
record.stop()
pkg_energy = record.energy(pyRAPL.PKG)
dram_energy = record.energy(pyRAPL.DRAM)

with the supported masks: pyRAPL.PKG, pyRAPL.DRAM, pyRAPL.GPU, pyRAPL.ALL

This can be the basis for being included in a ContextManager and/or code annotation.

DRAM consumption output

Hi everyone,

I've noticed that the DRAM output is expressed in seconds.
"dram (Optional[List[float]]) โ€“ list of the RAM energy consumption -expressed in seconds- (one value for each socket) if None, no RAM energy consumption was recorded."

Can you explain why the energy consumption is not expressed in micro-Joules ?
Otherwise, how can I obtain the equivalence in Joules ?

Thank you,
Best regards.

Windows os error

Is it not supported in windows.getting an error
/sys/devices/system/cpu/present/ no such file or directory error.

iteration

Hi,
Is it pyRAPL available for windows? what can be used for windows?

when the "number" is set >1, is a for loop required to run the function or measureit decorator measures it in iteration of number itself?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.