powerapi-ng / pyrapl Goto Github PK
View Code? Open in Web Editor NEWa library to measure the python energy consumption of python code
License: MIT License
a library to measure the python energy consumption of python code
License: MIT License
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
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.
add instance of the abstract class Output
Use pyRAPL on multiple architecture :
Hi,
When I try your demo code (from PyPI and this repo):
import pyRAPL
pyRAPL.setup()
@pyRAPL.measure
def foo():
# Instructions to be evaluated.
foo()
I get an attribute error: AttributeError: module 'pyRAPL' has no attribute 'measure'
.
Can I please request guidance?
Thank you!
Steph
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?
Tutorial in RTD and README
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
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.
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.
Is it not supported in windows.getting an error
/sys/devices/system/cpu/present/ no such file or directory error.
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?
I ran the example with a simple loop:
import pyRAPL
pyRAPL.setup()
@pyRAPL.measureit
def foo():
a = 0
for x in range(10000000000):
a += x
print(x)
foo()
and it gave the above error. It looks like a Linux directory.
Surprised it doesn't support Windows (or did I miss something?)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.