Pull requests / #1876
#1876 Add opt-in cumulative GPU energy monitoring to the Power card
open · @hash13 · 0 comentários · No GitHub
Descrição
Extended version with electricity pricing: https://github.com/Niko1221/Strata/pull/1925
## Summary
This PR adds opt-in cumulative GPU energy monitoring 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.
This is intentionally a small first step, without request-level energy attribution or token cost calculations.
## Screenshot
<img width="357" height="209" alt="grafik" src="https://github.com/user-attachments/assets/037ae159-4358-4d6d-a12c-7ed3377a9ffd" />
## Configuration
Enable energy monitoring by adding an `electricity` block at the top level of the existing Strata JSON configuration:
```json
"electricity": {}
```
An empty object is sufficient to enable the feature.
Without this block, the existing Power card remains unchanged.
Electricity prices and currency settings are not used in this initial version.
## Power Card
The existing Power card continues to display:
- Current GPU power consumption (W)
- NVIDIA power limit (W)
- Power history sparkline
When enabled, it additionally displays cumulative GPU energy consumption since telemetry started.
Example:
```text
Power
70 W
of 440 W limit · 26.0 Wh
```
Energy values are formatted using the browser's locale:
| Energy consumption | Display |
|---|---|
| Below 1 kWh | Wh, one decimal place |
| From 1 kWh | kWh, three decimal places |
The accumulated value updates automatically through the existing Monitor refresh cycle.
## Energy Measurement
The implementation prefers NVIDIA's cumulative NVML hardware energy counter (`nvmlDeviceGetTotalEnergyConsumption`).
Unlike integrating periodically sampled power readings, the hardware counter directly reports accumulated energy. This provides more reliable measurements, particularly when GPU power changes between samples.
If the hardware counter is unavailable, energy consumption is estimated by integrating the existing GPU power readings over time.
For multi-GPU configurations, the energy consumption of monitored GPUs is aggregated.
The accumulated energy is kept in memory and resets when Strata restarts.
## Scope
The cumulative energy value is exposed through the existing `/metrics` hardware data.
Measurement covers GPU energy only. CPU, RAM, motherboard, storage, fans, and PSU losses are not included.
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
| File | Changes |
|---|---|
| `serve/telemetry.py` | Cumulative GPU energy measurement using NVML with sampled-power fallback |
| `serve/server.py` | Optional `electricity` configuration passed to telemetry |
| `serve/web/app.js` | Wh/kWh display in the existing Power card |
No site
Links install, modelos, releases.