[PR #1925] [CLOSED] Add optional GPU electricity cost display to Power card #3760

Closed
opened 2026-11-07 15:30:34 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1925
Author: @hash13
Created: 10/11/2026
Status: ❌ Closed

Base: main ← Head: feature/monitor-gpu-electricity-cost


📝 Commits (2)

  • 4b8ba58 feat(monitor): add opt-in cumulative GPU energy tracking
  • 51134b6 feat(monitor): show GPU electricity costs in Power card

📊 Changes

3 files changed (+104 additions, -3 deletions)

View changed files

📝 serve/server.py (+3 -1)
📝 serve/telemetry.py (+54 -1)
📝 serve/web/app.js (+47 -1)

📄 Description

Minimal version without electricity pricing: https://github.com/Niko1221/Strata/pull/1876

Add opt-in GPU energy and electricity cost monitoring to the Power card

Summary

This PR adds opt-in GPU energy monitoring and optional electricity cost calculations to the existing Power card, based on Strata v0.1.42.

The implementation reuses Strata's existing GPU telemetry, multi-GPU support, and Monitor refresh infrastructure. No additional services, dependencies, or persistent storage are required.

The changes are intentionally limited to cumulative GPU energy consumption and total electricity costs.

There is no request-level energy attribution, token cost calculation, or additional details dialog.

Screenshot

grafik

Configuration

GPU energy monitoring is enabled by adding an electricity block at the top level of the existing Strata JSON configuration.

Energy monitoring only:

"electricity": {}

An empty object is sufficient to enable cumulative energy monitoring.

Energy monitoring with electricity costs:

"electricity": {
  "price_per_kwh": 0.32,
  "currency": "EUR"
}
  • price_per_kwh: Electricity price per kWh in the configured currency (e.g. 0.32 = €0.32/kWh).
  • currency: Currency code used for displaying electricity costs (defaults to EUR).
  • Both settings are optional. Without a valid price, only energy consumption is displayed.

Without an electricity block, GPU energy monitoring is disabled and the existing Power card remains unchanged.

Power Card

The existing Power card continues to display:

  • Current GPU power consumption (W)
  • NVIDIA power limit (W)
  • Power history sparkline

When electricity pricing is configured, the card uses a compact two-column layout:

Left Right
Current GPU power (W) Accumulated electricity cost
NVIDIA power limit (W) Accumulated GPU energy (Wh/kWh)

Example:

Power Electricity cost
278 W 0.155 €
of 520 W limit 483.0 Wh

The layout reuses the existing Speed card styling, without introducing additional CSS or increasing the card height.

When only energy monitoring is enabled, cumulative energy consumption is displayed alongside the existing power limit.

All values update automatically through the existing Monitor refresh cycle.

Value Formatting

Energy consumption:

Consumption Display
Below 1 kWh Wh, one decimal place
From 1 kWh kWh, three decimal places

Electricity costs:

Cost Display
Positive values below 0.001 < 0.001 €
Below 10 Three decimal places
From 10 Two decimal places

The currency symbol is displayed in a smaller font, matching the existing unit styling.

Number formatting follows the browser's locale.

Energy Measurement

The implementation prefers NVIDIA's cumulative NVML hardware energy counter (nvmlDeviceGetTotalEnergyConsumption).

This provides accumulated energy directly in millijoules and avoids estimating consumption solely from periodically sampled power values.

If the hardware counter is unavailable, energy is estimated by integrating the existing GPU power samples over time.

For multi-GPU configurations, energy consumption is aggregated across the monitored GPUs.

Energy accumulation starts with the telemetry sampler and resets when Strata restarts.

Electricity costs are calculated from accumulated energy:

Cost = GPU energy (kWh) × configured price per kWh

No additional NVML reads are required for the cost calculation.

Measurements cover GPU energy only. CPU, RAM, motherboard, storage, fans, and PSU losses are not included.

Operating Modes

Configuration Power Card Display
No electricity block Current GPU power (W) and power limit only
"electricity": {} GPU power, power limit, and cumulative energy consumption (Wh/kWh)
electricity with price_per_kwh Two-column layout: GPU power and power limit on the left; total electricity cost and cumulative energy consumption on the right

Configuration Examples

Energy monitoring only:

"electricity": {}

Energy monitoring with electricity costs:

"electricity": {
  "price_per_kwh": 0.32,
  "currency": "EUR"
}
  • price_per_kwh: Required to calculate electricity costs.
  • currency: Optional, defaults to EUR. Explicit configuration is recommended.
  • Without a valid electricity price, only cumulative GPU energy consumption is displayed.
  • Without an electricity block, energy monitoring remains disabled.

Electricity costs are calculated as:

Cost = accumulated GPU energy (kWh) × price_per_kwh

Scope

Cumulative energy consumption is exposed through the existing /metrics hardware data. The optional electricity price and currency are provided through the existing static telemetry data.

Request-level energy attribution is deferred to a later PR, initially limited to serial requests to avoid double counting energy during overlapping requests.

Changed Files

The complete implementation, including the optional electricity cost extension, affects three files:

File Changes
serve/telemetry.py Cumulative GPU energy measurement, NVML fallback, and optional electricity price configuration
serve/server.py Pass the optional electricity configuration to telemetry
serve/web/app.js Display cumulative GPU energy and optional electricity costs in the Power card

The electricity cost extension itself only modifies serve/telemetry.py and serve/web/app.js.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/1925 **Author:** [@hash13](https://github.com/hash13) **Created:** 10/11/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/monitor-gpu-electricity-cost` --- ### 📝 Commits (2) - [`4b8ba58`](https://github.com/Niko1221/Strata/commit/4b8ba58aba3ecbb1db9b7ef2cfef27e339b4b2e7) feat(monitor): add opt-in cumulative GPU energy tracking - [`51134b6`](https://github.com/Niko1221/Strata/commit/51134b6cad6789d36df98ce2fd2aa10d44f3c02c) feat(monitor): show GPU electricity costs in Power card ### 📊 Changes **3 files changed** (+104 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+3 -1) 📝 `serve/telemetry.py` (+54 -1) 📝 `serve/web/app.js` (+47 -1) </details> ### 📄 Description Minimal version without electricity pricing: https://github.com/Niko1221/Strata/pull/1876 # Add opt-in GPU energy and electricity cost monitoring to the Power card ## Summary This PR adds opt-in GPU energy monitoring and optional electricity cost calculations to the existing Power card, based on Strata v0.1.42. The implementation reuses Strata's existing GPU telemetry, multi-GPU support, and Monitor refresh infrastructure. No additional services, dependencies, or persistent storage are required. The changes are intentionally limited to cumulative GPU energy consumption and total electricity costs. There is no request-level energy attribution, token cost calculation, or additional details dialog. ## Screenshot <img width="353" height="212" alt="grafik" src="https://github.com/user-attachments/assets/efc6d451-e2b2-47f9-ad10-faaec18ab68f" /> ## Configuration GPU energy monitoring is enabled by adding an `electricity` block at the top level of the existing Strata JSON configuration. **Energy monitoring only:** ```json "electricity": {} ``` An empty object is sufficient to enable cumulative energy monitoring. **Energy monitoring with electricity costs:** ```json "electricity": { "price_per_kwh": 0.32, "currency": "EUR" } ``` - `price_per_kwh`: Electricity price per kWh in the configured currency (e.g. `0.32` = €0.32/kWh). - `currency`: Currency code used for displaying electricity costs (defaults to `EUR`). - Both settings are optional. Without a valid price, only energy consumption is displayed. Without an `electricity` block, GPU energy monitoring is disabled and the existing Power card remains unchanged. ## Power Card The existing Power card continues to display: - Current GPU power consumption (W) - NVIDIA power limit (W) - Power history sparkline When electricity pricing is configured, the card uses a compact two-column layout: | Left | Right | |---|---| | Current GPU power (W) | Accumulated electricity cost | | NVIDIA power limit (W) | Accumulated GPU energy (Wh/kWh) | **Example:** | Power | Electricity cost | |---|---| | **278 W** | **0.155 €** | | of 520 W limit | 483.0 Wh | The layout reuses the existing Speed card styling, without introducing additional CSS or increasing the card height. When only energy monitoring is enabled, cumulative energy consumption is displayed alongside the existing power limit. All values update automatically through the existing Monitor refresh cycle. ### Value Formatting **Energy consumption:** | Consumption | Display | |---|---| | Below 1 kWh | Wh, one decimal place | | From 1 kWh | kWh, three decimal places | **Electricity costs:** | Cost | Display | |---|---| | Positive values below 0.001 | < 0.001 € | | Below 10 | Three decimal places | | From 10 | Two decimal places | The currency symbol is displayed in a smaller font, matching the existing unit styling. Number formatting follows the browser's locale. ## Energy Measurement The implementation prefers NVIDIA's cumulative NVML hardware energy counter (`nvmlDeviceGetTotalEnergyConsumption`). This provides accumulated energy directly in millijoules and avoids estimating consumption solely from periodically sampled power values. If the hardware counter is unavailable, energy is estimated by integrating the existing GPU power samples over time. For multi-GPU configurations, energy consumption is aggregated across the monitored GPUs. Energy accumulation starts with the telemetry sampler and resets when Strata restarts. Electricity costs are calculated from accumulated energy: **Cost = GPU energy (kWh) × configured price per kWh** No additional NVML reads are required for the cost calculation. Measurements cover GPU energy only. CPU, RAM, motherboard, storage, fans, and PSU losses are not included. ### Operating Modes | Configuration | Power Card Display | |---|---| | No `electricity` block | Current GPU power (W) and power limit only | | `"electricity": {}` | GPU power, power limit, and cumulative energy consumption (Wh/kWh) | | `electricity` with `price_per_kwh` | Two-column layout: GPU power and power limit on the left; total electricity cost and cumulative energy consumption on the right | ### Configuration Examples **Energy monitoring only:** ```json "electricity": {} ``` **Energy monitoring with electricity costs:** ```json "electricity": { "price_per_kwh": 0.32, "currency": "EUR" } ``` - `price_per_kwh`: Required to calculate electricity costs. - `currency`: Optional, defaults to `EUR`. Explicit configuration is recommended. - Without a valid electricity price, only cumulative GPU energy consumption is displayed. - Without an `electricity` block, energy monitoring remains disabled. Electricity costs are calculated as: **Cost = accumulated GPU energy (kWh) × price_per_kwh** ## Scope Cumulative energy consumption is exposed through the existing `/metrics` hardware data. The optional electricity price and currency are provided through the existing static telemetry data. Request-level energy attribution is deferred to a later PR, initially limited to serial requests to avoid double counting energy during overlapping requests. ## Changed Files The complete implementation, including the optional electricity cost extension, affects three files: | File | Changes | |---|---| | `serve/telemetry.py` | Cumulative GPU energy measurement, NVML fallback, and optional electricity price configuration | | `serve/server.py` | Pass the optional `electricity` configuration to telemetry | | `serve/web/app.js` | Display cumulative GPU energy and optional electricity costs in the Power card | The electricity cost extension itself only modifies `serve/telemetry.py` and `serve/web/app.js`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:30:34 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#3760
No description provided.