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

Measurements error #17

Open
manceaur opened this issue Nov 25, 2022 · 3 comments
Open

Measurements error #17

manceaur opened this issue Nov 25, 2022 · 3 comments

Comments

@manceaur
Copy link

manceaur commented Nov 25, 2022

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

@bekiroguzhan
Copy link

I am having the same issue with Ubuntu 16.04 TLS and python 3.7.

@sohanpatil1
Copy link

I got the same error, did anyone figure it out? Using Ubuntu 20.04 and python 3.8.
I changed the code to this,
_pkg = [j / number for j in self.pkg] if self.pkg else None
_dram = [j / number for j in self.dram] if self.dram else None
But I haven't studied it enough to know if this is correct.

@kinow
Copy link

kinow commented Feb 24, 2024

Had the same, in my case it looks like the dram metrics/list is not populated. The class attribute is Optional (thanks for the type hints!), but the code doesn't seem to take that into consideration when iterating it. I fixed it locally to ignore the dram for now (couldn't find if I have to enable something on Ubuntu) with this code:

_dram = [] if self.dram is None else [j / number for j in self.dram]

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

No branches or pull requests

4 participants