brndnmtthws / conky

Light-weight system monitor for X, Wayland (sort of), and other things, too
https://conky.cc
GNU General Public License v3.0
7.17k stars 615 forks source link

Support for Intel's RAPL measurements #533

Closed Brainiarc7 closed 11 months ago

Brainiarc7 commented 6 years ago

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?

lasers commented 6 years ago

@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.

su8 commented 6 years ago

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.

lasers commented 6 years ago

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

su8 commented 6 years ago

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.

lasers commented 6 years ago
[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
lasers commented 6 years ago

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?

su8 commented 6 years ago

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.

su8 commented 6 years ago

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

lasers commented 6 years ago

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

lasers commented 6 years ago

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
Brainiarc7 commented 6 years ago

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

lasers commented 6 years ago

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.

lasers commented 6 years ago

This will definitely help you.

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

adrianmarino commented 3 years ago

In Arch Linux binutils package is required to compile rapl-read.c.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 365 days with no activity. Remove stale label or comment, or this issue will be closed in 30 days.

github-actions[bot] commented 11 months ago

This issue was closed because it has been stalled for 30 days with no activity.