Viewing GPU usage
GPU usage is retrieved using the gnocchi aggregates command.
Prerequisites
- GPU metrics are created, as described in Managing GPU metrics.
To view GPU usage for a project
Use the following command:
# gnocchi --insecure aggregates --resource-type instance "(aggregate sum (metric <metric_name> mean))" \ "project_id=<project_id>" --start <start_date> --stop <stop_date>
For example, to view GPU usage for the metric gpu.nvidia_319 in the project with the ID 87abf18490ea433fbaab701d1727b6ad, run:
# gnocchi --insecure aggregates --resource-type instance "(aggregate sum (metric gpu.nvidia_319 mean))" \ "project_id=87abf18490ea433fbaab701d1727b6ad" --start 2026-03-01T00:00:00 --stop 2026-03-31T23:59:59 +------------+---------------------------+--------------+-------+ | name | timestamp | granularity | value | +------------+---------------------------+--------------+-------+ | aggregated | 2026-03-16T16:20:00+00:00 | 300000000000 | 1.0 | | aggregated | 2026-03-16T16:35:00+00:00 | 300000000000 | 1.0 | | aggregated | 2026-03-16T16:40:00+00:00 | 300000000000 | 2.0 | | aggregated | 2026-03-16T16:45:00+00:00 | 300000000000 | 2.0 | | aggregated | 2026-03-16T16:50:00+00:00 | 300000000000 | 2.0 | +------------+---------------------------+--------------+-------+
The value column shows the number of GPUs allocated to virtual machines belonging to the specified project during the polling interval.
To calculate GPU-hours for a given period, multiply the returned values by the polling interval and sum the results over the desired time range. For example, with a 5-minute polling interval:
GPU-hours = Σ (GPU count × 5 minutes) / 60
GPU metrics can be queried separately for each configured GPU metric to obtain usage breakdowns by GPU type.