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

refactor: better pacakge naming strategy #3

Open
altor opened this issue Jan 8, 2020 · 12 comments
Open

refactor: better pacakge naming strategy #3

altor opened this issue Jan 8, 2020 · 12 comments

Comments

@altor
Copy link
Contributor

altor commented Jan 8, 2020

the class that will be mainly used (measureit, EnergyContext, Sample) must be located in the pyJoules package

@pallavimitra
Copy link

Hello,

I am trying to use pyJoules to measure the energy consumption of my workloads.

The very basic error I am getting when trying to run a simple function is that -

the measureit is not present in the source code of pyjoules.energy_meter.

is there any solution to this?

The error is as follows:

``ImportError Traceback (most recent call last)
in
----> 1 from pyJoules.energy_meter import measureit
2
3 @Measureit
4
5 def recursive_fib(n):

ImportError: cannot import name 'measureit' from 'pyJoules.energy_meter' (C:\Users\PALLAVI\anaconda3\lib\site-packages\pyJoules\energy_meter.py)"

@altor
Copy link
Contributor Author

altor commented Nov 16, 2020

Hello !

Sorry, the Readme file was not updated since the last release. I've just fix it.

The measureit decorator was rename into measure_energy decorator

If you need, you can find more example in the documentation : https://pyjoules.readthedocs.io/en/latest/usages/usage.html

@pallavimitra
Copy link

@altor Thanks for the quick reply. Now the problem is solved.

But it has some new issue in energy_meter.py code and the error is coming as follows:

~\anaconda3\lib\site-packages\pyJoules\energy_meter.py in _get_domain_list(self)
164 return the list of all monitored domains for each monitored energy devices
165 """
--> 166 return reduce(operator.add, [device.get_configured_domains() for device in self.devices])
167
168 def _generate_trace(self):

TypeError: reduce() of empty sequence with no initial value

@altor
Copy link
Contributor Author

altor commented Nov 18, 2020

Could you post the piece of code that give you this issue ?

@pallavimitra
Copy link

from pyJoules.energy_meter import measure_energy

@measure_energy

def recursive_fib(n):
if (n <= 2): return 1
else: return recursive_fib(n-1) + recursive_fib(n-2)

recursive_fib(10)

@gioperin
Copy link

gioperin commented Nov 23, 2020

Hello,

I have the same exact problem, running:

import numpy as np

@measure_energy
def foo():
    # Instructions to be evaluated.
    np.random.rand(1000)
foo()

will give the following error:

TypeError                                 Traceback (most recent call last)
<ipython-input-6-13f5a55d2f3c> in <module>
      6     # Instructions to be evaluated.
      7     np.random.rand(1000)
----> 8 foo()

C:\ProgramData\Anaconda3\envs\tfkeras\lib\site-packages\pyJoules\energy_meter.py in wrapper_measure(*args, **kwargs)
    296             val = func(*args, **kwargs)
    297             energy_meter.stop()
--> 298             handler.process(energy_meter.get_trace())
    299             return val
    300         return wrapper_measure

C:\ProgramData\Anaconda3\envs\tfkeras\lib\site-packages\pyJoules\energy_meter.py in get_trace(self)
    158             raise EnergyMeterNotStoppedError()
    159 
--> 160         return self._generate_trace()
    161 
    162     def _get_domain_list(self):

C:\ProgramData\Anaconda3\envs\tfkeras\lib\site-packages\pyJoules\energy_meter.py in _generate_trace(self)
    167 
    168     def _generate_trace(self):
--> 169         domains = self._get_domain_list()
    170         generator = TraceGenerator(self._first_state, domains)
    171         return generator.generate()

C:\ProgramData\Anaconda3\envs\tfkeras\lib\site-packages\pyJoules\energy_meter.py in _get_domain_list(self)
    164         return the list of all monitored domains for each monitored energy devices
    165         """
--> 166         return reduce(operator.add, [device.get_configured_domains() for device in self.devices])
    167 
    168     def _generate_trace(self):

TypeError: reduce() of empty sequence with no initial value

@altor
Copy link
Contributor Author

altor commented Nov 23, 2020

Hello !
Ok, I have other questions :

  • what is your exploitation system ?
  • If it's GNU/Linux, could you post the result of the following command ls /sys/class/powercap/
  • what is your CPU architecture ?
  • have you got a GPU card on your computer ? if yes what is its model and have you got nvml installed on your machine ?

@pallavimitra
Copy link

@altor It is a windows system and has no GPU card.

@altor
Copy link
Contributor Author

altor commented Nov 23, 2020

@pallavimitra Ok, sorry but pyJoules don't have support for windows system. You have to run it on GNU/Linux

for mac user we try to add support for macOS soon but for the moment you can use this tool : https://github.com/chakib-belgaid/IJoules

@gioperin
Copy link

Ok, I was running on Windows too. However, in Linux, there are annoying problems of permissions on the file energy_uj that I wasn't able to solve. I saw the last issue was opened with the same problem but I wasn't able to follow the solution.

@altor
Copy link
Contributor Author

altor commented Nov 23, 2020

EDIT :
this issue seems to be related to a security vulnerability
A security patch now restrict reading energy value only for privileged users (root)
So don't change permissions of any file it's a security vulnerability


Old Message don't follow theses advice this will make security vulnerability on your system

Thanks for your feedback !
We don't know why this issue appear, we are investigating ...

For the moment, you could change the permission of the following files to be readable by the user that use pyJoules :

  • /sys/class/powercap/intel-rapl:*/energy_uj
  • /sys/class/powercap/intel-rapl:*:*/energy_uj

In order to help us to find a better solution, could you give us the result of the following commands :

  • uname -a
  • lsmod

@altor
Copy link
Contributor Author

altor commented Nov 24, 2020

Hello !
This issue seems to be related to a security vulnerability
A security patch now restrict reading energy value only for privileged users (root)
So don't change permissions of any file it's a security vulnerability

If you want to talk about this issue please go to the related thread (#13)

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

3 participants