pyJoules icon indicating copy to clipboard operation
pyJoules copied to clipboard

refactor: better pacakge naming strategy

Open altor opened this issue 5 years ago • 12 comments

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

altor avatar Jan 08 '20 10:01 altor

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)"

pallavimitra avatar Nov 16 '20 12:11 pallavimitra

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

altor avatar Nov 16 '20 15:11 altor

@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

pallavimitra avatar Nov 16 '20 23:11 pallavimitra

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

altor avatar Nov 18 '20 15:11 altor

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)

pallavimitra avatar Nov 19 '20 09:11 pallavimitra

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

gioperin avatar Nov 23 '20 09:11 gioperin

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 ?

altor avatar Nov 23 '20 10:11 altor

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

pallavimitra avatar Nov 23 '20 11:11 pallavimitra

@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

altor avatar Nov 23 '20 11:11 altor

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.

gioperin avatar Nov 23 '20 13:11 gioperin

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 avatar Nov 23 '20 15:11 altor

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)

altor avatar Nov 24 '20 10:11 altor