Resolving DEVICE_IN_USE() Error for Hailo Devices

Overview of the Problem:
The DEVICE_IN_USE() error typically indicates that the Hailo device (usually /dev/hailo0) is currently being accessed or locked by another process. This can happen during concurrent access attempts or if a previous process did not terminate cleanly, leaving the device in a locked state.

Steps to Resolve:

1. Identify the Device:
Typically, the Hailo device is located at /dev/hailo0. Ensure that this is the correct device file for your setup.

2. Find Processes Using the Device:
Run the following command to list any processes currently using the Hailo device:
sudo lsof /dev/hailo0
Note the PID (Process ID) of any processes listed.

3. Terminate the Offending Process:
If a process is using the device, and you are sure it’s safe to terminate, use the following command:
sudo kill -9 PID
Replace PID with the actual Process ID you noted earlier.

Scripted option:
Here’s a more robust and simplified script to automate the process.

#!/bin/bash
# Define Hailo device
HAILO_DEVICE="/dev/hailo0"
# Find and kill any processes using the Hailo device
for pid in $(sudo lsof -t $HAILO_DEVICE); do
  echo "Terminating process $pid using $HAILO_DEVICE"
  sudo kill -9 $pid
done
echo "All processes using $HAILO_DEVICE have been terminated."

This script automatically finds and terminates all processes using the Hailo device.

Final Note:
If the above steps do not resolve the issue, a system reboot might be necessary. Rebooting the system will terminate all processes and release any locks on the device. However, ensure to save any important work before rebooting as unsaved data might be lost.
By following these steps, you should be able to resolve the DEVICE_IN_USE() error and regain access to your Hailo device. If problems persist, consider reaching out to Hailo’s support or community forum for further assistance.

If you found this (or other posts) useful, please hit the :heart: button to help promote it to more people. Have insights, corrections, or questions? Share your thoughts in the comments!

3 Likes