Using the glances[gpu]
package, adding GPU support client-side is a simple as running pip install glances[gpu]
.
Glances will report a list of all GPUs on the system with the following basic statistics:
Either:
http://hostname:61208/api/3/gpu
[
{
"key": "gpu_id",
"gpu_id": 0,
"name": "NVIDIA GeForce RTX 4080",
"mem": 13.333489176233513,
"proc": 12,
"temperature": 38,
"fan_speed": 30
}
]
Or:
http://hostname:61208/api/3/all
{
"gpu": [
{
"key": "gpu_id",
"gpu_id": 0,
"name": "NVIDIA GeForce RTX 4080",
"mem": 13.455118198888618,
"proc": 2,
"temperature": 38,
"fan_speed": 30
}
]
}
mem
and proc
are percentages.
temperature
is celcius.
fan_speed
appears to be the average fan speed, but I will check the documentation to confirm this.
The addon seems to support Windows, macOS and Linux and as it returns an array it also supports multi-GPU systems.
Fixes required (approximately):
core/homeassistant/components/glances/sensor.py at dev · home-assistant/core (github.com)
Add the following sensor definitions:
("gpu", "name"): GlancesSensorEntityDescription(
key="name",
type="gpu",
name_suffix="Name",
icon="mdi:expansion-card",
state_class=SensorStateClass.MEASUREMENT,
),
("gpu", "mem"): GlancesSensorEntityDescription(
key="mem",
type="gpu",
name_suffix="Memory",
icon="mdi:memory",
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
),
("gpu", "proc"): GlancesSensorEntityDescription(
key="proc",
type="gpu",
name_suffix="Core",
icon="mdi:cpu-64-bit",
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
),
("gpu", "temperature"): GlancesSensorEntityDescription(
key="temperature",
type="gpu",
name_suffix="Temperature",
icon="mdi:thermometer",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
),
("gpu", "fan_speed"): GlancesSensorEntityDescription(
key="fan_speed",
type="gpu",
name_suffix="Fan speed",
icon="mdi:fan",
native_unit_of_measurement=PERCENT,
state_class=SensorStateClass.MEASUREMENT,
),
core/homeassistant/components/glances/sensor.py at dev · home-assistant/core (github.com):
Add gpu
to list of multi-component sensors.