Glances integration GPU support (via glances[gpu] package)

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.

Hi Kristian,

I started working on this. Please let me know if you have already implemented this, otherwise I will continue and will let you know when it is released!

I agree this should be implemented, this is how I have done it until now: System monitoring with Glances in Home-Assistant - Flemming's Blog
(but I don’t use Glances anymore)

1 Like

Looks like I’m a few days late: neuralyze did it already.

Now it’s just a matter of getting it merged in python-glances-api, then the component code in Home Assistant can be updated, along with the version bump for python-glances-api

My programming skills do not currently extend to Python so I didn’t start, cool to see the idea taking off though!

1 Like

Almost there…