Skip to content

energyawareOS/enelog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

enelog

enelog is a lightweight command-line utility for measuring CPU power consumption using Intel's RAPL (Running Average Power Limit) interface. It is implemented in C and built with CMake.

Features

  • CPU package power & energy via Intel RAPL
  • Optional DRAM domain power & energy (-d)
  • Optional GPU total and per-GPU power & energy via NVIDIA NVML (-g, -G)

Requirements

  • OS: Linux with /sys/class/powercap (RAPL) support. You may need to have root privileges.
  • OS: Linux with /sys/class/powercap (RAPL) support. You may need to have root privileges.
  • CPU: Intel processor with RAPL package—and optionally DRAM—domains
  • GPU (optional): NVIDIA driver + NVML (libnvidia-ml.so) if using -g/-G
  • Permissions: Reading energy_uj may require sudo on some systems

Build Instructions

Make sure you have CMake (version 3.22 or higher) and a C compiler installed.

git clone https://github.com/your-username/enelog.git
cd enelog
cmake -B build
cmake --build build

After building, the executable will be available at build/enelog.

Building

  • CPU-only
cmake -B build \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_C_FLAGS="-I/usr/local/cuda/include" \
  -DCMAKE_EXE_LINKER_FLAGS="-L/usr/lib/x86_64-linux-gnu -lnvidia-ml"
cmake --build build

Adjust include/lib paths for your distribution (e.g., /usr/lib, /lib/x86_64-linux-gnu, /usr/local/cuda/lib64).

  • NVML-enabled build (includ GPU)
cmake -B build -DUSE_NVML=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build

Usage

./enelog [-i <interval>] [-t <timeout>] [-d] [-D] [-E] [-H] [-h] [-g] [-G]
  • -i <interval>: Interval in seconds between power measurements (default: 1 second)
  • -t <timeout>: Timeout in seconds after which the program exits (default: 120 seconds)
  • -d: Enable DRAM power/energy (if DRAM RAPL domain exists)
  • -D: Prepend MM-DD to the timestamp (otherwise HH:MM:SS)
  • -E: Include energy(J) fields in output (otherwise power only)
  • -H: Print a one-line header describing the output columns
  • -h: Show help and exit
  • -h: Show help and exit

GPU (requires NVML and a build with USE_NVML=ON):

  • -g: Enable GPU power/energy measurement via NVML
  • -G: Also print per-GPU metrics(implies -g)

Output Schema

Timestamp

  • Default: HH:MM:SS
  • With -D: MM-DD HH:MM:SS

Columns (by flags)

  • Base (CPU only, no -E):

    [time] CPU(W)
    
  • CPU with energy (-E):

    [time] CPU(W) CPU(J)
    
  • CPU + DRAM (-d, no -E):

    [time] CPU(W) DRAM(W)
    
  • CPU + DRAM with energy (-d -E):

    [time] CPU(W) CPU(J) DRAM(W) DRAM(J)
    
  • Add GPU total (-g):

    [time] ... GPU(W) [GPU(J) if -E]
    
  • Add per-GPU (-G):

    [time] ... GPU(W) [GPU(J)] GPU00(W) [GPU00(J)] GPU01(W) [GPU01(J)] ...
    

License

This project is licensed under the MIT License. See the LICENSE file for details.

Notes

  • Platform support

    • Requires Linux with RAPL exposed under /sys/class/powercap.
    • Works on Intel CPUs that support RAPL. AMD/others are not supported.
    • Only package 0 (intel-rapl:0) is read; multi-socket systems beyond pkg0 are not measured.
    • The DRAM RAPL domain may not be present on all platforms.
  • Permissions

    • Reading energy_uj may require elevated privileges. Use sudo or adjust permissions via a udev rule (distro-specific).
  • DRAM flag (-d)

    • If your system lacks a DRAM RAPL domain, using -d will fail. Omit -d in that case.
  • GPU measurement (-g, -G)

    • Requires NVIDIA driver + NVML (libnvidia-ml.so and a build with -DUSE_NVML=ON).
    • -G includes per-GPU metrics and implies -g.
    • If NVML isn’t available or no NVIDIA GPUs are present, GPU measurement will not work.
  • Timing & alignment

    • Using absolute time scheduling, sampling is aligned to second-of-minute boundaries.
    • By this, timing alignment is consistent for running
  • Units & fields

    • Power is in watts (W) and energy in joules (J).
    • Use -E to include energy columns; -H prints a header row; -D adds MM-DD to the timestamp.
  • Accuracy considerations

    • CPU energy uses RAPL counters (platform-estimated). GPU energy is trapezoid-integrated from instantaneous NVML power.
    • Shorter intervals generally improve integration accuracy but increase overhead.
  • Containers/VMs

    • Some containers or virtual machines do not expose /sys/class/powercap or NVML; measurements may be unavailable there.
  • More info

About

Tracking CPU power using RAPL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •