powerapi-ng / pyJoules

A Python library to capture the energy consumption of code snippets
MIT License
69 stars 8 forks source link

Unable to measure DRAM energy consumption. #26

Open hafizuriu opened 1 year ago

hafizuriu commented 1 year ago

@altor @rouvoy @chakib-belgaid @danglotb I have the following code snippet running on Ubuntu 22.04.1

from pyJoules.energy_meter import EnergyContext
from pyJoules.device.rapl_device import RaplDramDomain
from pyJoules.handler.csv_handler import CSVHandler

csv_handler = CSVHandler('result.csv')

with EnergyContext(handler=csv_handler, domains=[RaplDramDomain(0)], start_tag='Test') as ctx:
    train()
 csv_handler.save_data()

I get the following stack trace error:

Traceback (most recent call last):
  File "/home/hafizur/test.py", line 8, in <module>
    with EnergyContext(handler=csv_handler, domains=[RaplDramDomain(0)], start_tag='Test') as ctx:
  File "/home/hafizur/anaconda3/envs/myenv/lib/python3.10/site-packages/pyJoules/energy_meter.py", line 322, in __init__
    devices = DeviceFactory.create_devices(domains)
  File "/home/hafizur/anaconda3/envs/myenv/lib/python3.10/site-packages/pyJoules/device/device_factory.py", line 78, in create_devices
    device.configure(domains=grouped_domains[device_type])
  File "/home/hafizur/anaconda3/envs/myenv/lib/python3.10/site-packages/pyJoules/device/rapl_device.py", line 211, in configure
    Device.configure(self, domains)
  File "/home/hafizur/anaconda3/envs/myenv/lib/python3.10/site-packages/pyJoules/device/device.py", line 64, in configure
    raise NoSuchDomainError(domain)
pyJoules.exception.NoSuchDomainError

Does pyJoles able to measure the energy consumption of DRAM? N.B: It can measure energy consumption of NVIDIA GPU. But think it measures energy in milli-joule, not micro-joule

chakib-belgaid commented 1 year ago

Hi hafizuriu, it seems like you are attempting to determine the DRAM usage on a laptop computer. Unfortunately, the RAPL technology (the registers provided by INTEL which we use to measure the energy consumption) does not support measuring DRAM for desktop CPUs like Intel Core 5, 7, 9, 11, etc. It is only available for XENON CPUs. Let me know if this answers your question.

hafizuriu commented 1 year ago

@altor @rouvoy @chakib-belgaid @danglotb

Thank you for your response @chakib-belgaid My other confusion is about the outputs that pyJoules return. It return as follows- begin timestamp : 1675697491.336882; tag : foo; duration : 3.7640533447265625; package_0 : 153976351.0; core_0 : 127869606.0; uncore_0 : 0.0; nvidia_gpu_0 : 192276

My question is if I want to measure the CPU energy consumption, what values should I have to take into account? What is the unit of package_0?

I think package_0 return energy in uJ (1e-6J) and Nvidia_gpu return in mJ (1e-3J)

Could you please help me to clarify this issues?

My machine details: 11th Gen Intel® Core™ i9-11900 @ 2.50GHz × 16 NVIDIA GeForce RTX 3060