Conky: Support for Intel's RAPL measurements

Created on 5 Jul 2018  路  13Comments  路  Source: brndnmtthws/conky

Hello there,

Can Conky be used to monitor modern Intel-based hardware's power draw (per RAPL domain)?

According to this article, reading RAPL values on current kernels (linux 3.13+) is possible without any special privileges.

Can such a feature be implemented, as a plugin?

enhancement

Most helpful comment

[aaron:/tmp] % ./rapl-read

RAPL read -- use -s for sysfs, -p for perf_event, -m for msr

Found Sandybridge-EP Processor type
    0 (0), 1 (0), 2 (0), 3 (0), 4 (0), 5 (0), 6 (0), 7 (0)
    8 (0), 9 (0), 10 (0), 11 (0), 
    Detected 12 cores in 1 packages


Trying sysfs powercap interface to gather results

    Sleeping 1 second

    Package 0
        package-0   : 21.221025J
        core    : 7.586354J
        dram    : 0.965191J

All 13 comments

@Brainiarc7 Hi. Do you still require this feature? Maybe you can expand more information on what you're hoping to see... Examples would be good too. Thanks.

There is an example program - http://web.eece.maine.edu/~vweaver/projects/rapl/rapl-read.c , but I don't have a intel cpu to test it out.

@su8 I can test this for you. :smile: Not sure how to make rapl-read.c

Compile with: gcc -O2 -Wall -o rapl-read rapl-read.c -lm

it requires:

Read the RAPL registers on recent (>sandybridge) Intel processors

So limiting the intel cpu to 2011 and onwards, it's linux exclusive too.

On top of that we have to keep updating every new cpu generation too.

[aaron:/tmp] % ./rapl-read

RAPL read -- use -s for sysfs, -p for perf_event, -m for msr

Found Sandybridge-EP Processor type
    0 (0), 1 (0), 2 (0), 3 (0), 4 (0), 5 (0), 6 (0), 7 (0)
    8 (0), 9 (0), 10 (0), 11 (0), 
    Detected 12 cores in 1 packages


Trying sysfs powercap interface to gather results

    Sleeping 1 second

    Package 0
        package-0   : 21.221025J
        core    : 7.586354J
        dram    : 0.965191J

On top of that we have to keep updating every new cpu generation too.

Maybe not. We can implement this to make this feature request possible. I also think conky would have fewer issues with this feature than... say Nvidia. Is there an exec alternative?

EDIT: What exactly are we trying to print? package-0? core? dram ? All three?

What exactly are we trying to print? package-0? core? dram ? All three?

DRAM

I think all three measures the consumed energy in joules, package 0 being the whole processor.

Can you run the program as root, to see whether it will print the rest consumption ?

Gotcha. I suggest we want for @Brainiarc7 to exactly tell us what he's looking for in conky. root printed the same thing too.

Oh wait, there are arguments...

# sudo ./rapl-read -s
RAPL read -- use -s for sysfs, -p for perf_event, -m for msr

Found Sandybridge-EP Processor type
        0 (0), 1 (0), 2 (0), 3 (0), 4 (0), 5 (0), 6 (0), 7 (0)
        8 (0), 9 (0), 10 (0), 11 (0),
        Detected 12 cores in 1 packages


Trying sysfs powercap interface to gather results

        Sleeping 1 second

        Package 0
                package-0       : 24.018060J
                core    : 10.314195J
                dram    : 0.984981J
# sudo ./rapl-read -p
RAPL read -- use -s for sysfs, -p for perf_event, -m for msr

Found Sandybridge-EP Processor type
    0 (0), 1 (0), 2 (0), 3 (0), 4 (0), 5 (0), 6 (0), 7 (0)
    8 (0), 9 (0), 10 (0), 11 (0),
    Detected 12 cores in 1 packages


Trying perf_event interface to gather results

    Event=energy-cores Config=1 scale=2.32831e-10 units=Joules
    Event=energy-pkg Config=2 scale=2.32831e-10 units=Joules
    Event=energy-ram Config=3 scale=2.32831e-10 units=Joules

    Sleeping 1 second

    Package 0:
        energy-cores Energy Consumed: 7.249084 Joules
        energy-pkg Energy Consumed: 20.877182 Joules
        energy-ram Energy Consumed: 0.933990 Joules
# sudo ./rapl-read -m
rdmsr:open: No such file or directory
RAPL read -- use -s for sysfs, -p for perf_event, -m for msr

Found Sandybridge-EP Processor type
    0 (0), 1 (0), 2 (0), 3 (0), 4 (0), 5 (0), 6 (0), 7 (0)
    8 (0), 9 (0), 10 (0), 11 (0),
    Detected 12 cores in 1 packages


Trying /dev/msr interface to gather results

    Listing paramaters for package #0

Hey there,

Yes, I still need this feature, such that with conky, power draw values (in Watts/Joules) for the RAPL domains (Core, DRAM, Uncore) can be polled and printed out.

Ideally, conky should be able to display instantaneous power utilization for the aforementioned domains in a manner similar to how you can parse nvidia-smi output for power draw. See this config file as a starting point.

Line of interest:

${color1}GPU Power Draw ${color} ${exec nvidia-smi | grep % | cut -c 21-23} W

Since the nvidia module for Conky does not provide wattage measurements (to my knowledge, correct me if I'm wrong).

NVIDIA is broken on Conky right now for me #520.

I can't tell you anything if I wanted to. Maybe you can confirm it's not broken on current master? The differences might be that I have a legacy card and you don't.

(q) Can you try the current master?

git clone https://github.com/brndnmtthws/conky
cd conky
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_NVIDIA=ON ..
make -j4  # 4 cores to run in parallel
src/conky -c ~/conky.conf # <-- your config goes here

(offtopic)

${color1}GPU:${color #FCAF3E}${exec nvidia-smi --query-gpu=gpu_name --format=csv,noheader,nounits} $color
${color1}GPU Temperature ${color}  ${nvidia temp} 掳C
${color1}GPU Utilization ${color}  ${exec nvidia-smi | grep % | cut -c 61-63} %
${color1}GPU Core Frequency ${color}  ${nvidia gpufreq} MHz
${color1}GPU Memory Frequency ${color}  ${nvidia memfreq} MHz
${color1}VRAM Utilization ${color} ${exec nvidia-smi | grep % | cut -c 37-40} MB
${color1}GPU Power Draw ${color} ${exec nvidia-smi | grep % | cut -c 21-23} W

In your config, you're querying nvidia-smi --format=csv,noheader,nounits --query-gpu=name for your name... For others, you're querying things differently. The command above should have other properties that you can use... so you don't have to spend extra resources doing additional grep | cut calls. See nvidia-smi --help-query-gpu.

This will definitely help you.

$ wget https://raw.githubusercontent.com/ultrabug/py3status/master/py3status/modules/nvidia_smi.py && python nvidia_smi.py --list-properties

Was this page helpful?
0 / 5 - 0 ratings

Related issues

moyamo picture moyamo  路  3Comments

LeoIannacone picture LeoIannacone  路  3Comments

Microcrap picture Microcrap  路  4Comments

Dimerbone picture Dimerbone  路  4Comments

oberon-manjaro picture oberon-manjaro  路  4Comments