How to measure the power and temp of Hailo-8 M.2 async

There is a simple Python API to read-out the data from the temperature and power sensors. This can be executed async from any other activity on the device.

#!/usr/bin/env python3

import time
from hailo_platform import Device

def _run_periodic(delay=1):
    device_infos = Device.scan()
    targets = [Device(di) for di in device_infos]
    for i, target in enumerate(targets):
        target.control.stop_power_measurement()
        target.control.set_power_measurement()
        target.control.start_power_measurement()
    try:
        while True:
            for i, target in enumerate(targets):
                time.sleep(delay)
                power = target.control.get_power_measurement().average_value
                temp = target.control.get_chip_temperature().ts0_temperature
                print('[{}] {:.3f}W {:.3f}C'.format(device_infos[i], power, temp), end='\r')
    except KeyboardInterrupt:
        print('-I- Received keyboard intterupt, exiting')

    for i, target in enumerate(targets):
        target.control.stop_power_measurement()

if __name__ == "__main__":
    _run_periodic()
2 Likes

Thanks Nadav, that is very helpful. I would also be interested in querying which temperature zone HAILO is in as well as the current clock frequency through the python interface. Is that possible?

You can use the device control:

from hailo_platform import Device

dev = Device()
dev.control.get_extended_device_information()

This would output like this:
image

Temperature zones are preset, you can read the values in the hailort user guide in this chapter: “9.1. Temperature Monitoring”

1 Like

It looks like my Current monitoring is set to Disabled. Is there any way to enable it or does this mean that my board is incompatible? I’m using the Raspberry Pi M2.2 board. I was hoping to measure power draw.

H i to All,

I support the question about the current monitoring being disabls on Hailo8l on RP5. I also have “Current Monitoring: Disabled”

I see the following output when attempt measuring power:

[HailoRT] [error] Firmware control has failed. Major status: 0x400300b4, Minor status: 0x400300b4
[HailoRT] [error] Firmware major status: CONTROL_PROTOCOL_STATUS_UNSUPPORTED_DEVICE
[HailoRT] [error] Firmware minor status: CONTROL_PROTOCOL_STATUS_UNSUPPORTED_DEVICE
[HailoRT] [error] Opcode HAILO_CONTROL_OPCODE_SET_POWER_MEASUEMENT is not supported on the current board.

Thank you and best regards!

The Raspberry PI Ai kit doesn’t have the INA component, and so it cannot measure the power drawn by the device. But, it still has the temperature sensor, and so you can measure the temperature of the chip periodically like this:

#!/usr/bin/env python3

import time
from hailo_platform import Device

def _run_periodic(delay=1):
    target = Device()
    try:
        while True:
            temp = target.control.get_chip_temperature().ts0_temperature
            print(f'{temp:.2f} C', end='\r')
            time.sleep(delay)
    except KeyboardInterrupt:
        print('-I- Received keyboard intterupt, exiting')

if __name__ == "__main__":
    _run_periodic()

1 Like

Thank you for the answer! I would suggest updating the corresponding User Guide. The guide mentions INA component, however, I do not remember the guide mentioning that AI KIT doesn’t have it.

Hey i also have the error :slightly_frowning_face:
Is it related to a typo in the library somewhere?
HAILO_CONTROL_OPCODE_SET_POWER_MEASU R EMENT
Thanks for your replies

Can you share the code the yields that error on your side?