Skip to content

NVR with realtime local object detection for IP cameras

Update Hailo Driver to 4.19 (#14674)

Blake Blacksheard12c7809ddcf
diff --git a/docker/hailo8l/Dockerfile b/docker/hailo8l/Dockerfile
index 479ef9b27a..701c81d0f6 100644
--- a/docker/hailo8l/Dockerfile
+++ b/docker/hailo8l/Dockerfile
@@ -2,6 +2,9 @@
ARG DEBIAN_FRONTEND=noninteractive
+# NOTE: also update user_installation.sh
+ARG HAILO_VERSION=4.19.0
+
# Build Python wheels
FROM wheels AS h8l-wheels
@@ -19,6 +22,7 @@ RUN pip3 wheel --wheel-dir=/h8l-wheels -c /requirements-wheels.txt -r /requireme
# Build HailoRT and create wheel
FROM wheels AS build-hailort
ARG TARGETARCH
+ARG HAILO_VERSION
SHELL ["/bin/bash", "-c"]
@@ -50,55 +54,35 @@ RUN PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}' | cut -d. -f1,2)
RUN . /etc/environment && \
git clone https://github.com/hailo-ai/hailort.git /opt/hailort && \
cd /opt/hailort && \
- git checkout v4.18.0 && \
- cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release -DHAILO_BUILD_PYBIND=1 -DPYBIND11_PYTHON_VERSION=${PYTHON_VERSION} && \
+ git checkout v${HAILO_VERSION} && \
+ cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release && \
cmake --build build --config release --target libhailort && \
- cmake --build build --config release --target _pyhailort && \
- cp build/hailort/libhailort/bindings/python/src/_pyhailort.cpython-${PYTHON_VERSION_NO_DOT}-$(if [ $TARGETARCH == "amd64" ]; then echo 'x86_64'; else echo 'aarch64'; fi )-linux-gnu.so hailort/libhailort/bindings/python/platform/hailo_platform/pyhailort/ && \
- cp build/hailort/libhailort/src/libhailort.so hailort/libhailort/bindings/python/platform/hailo_platform/pyhailort/
-
-RUN ls -ahl /opt/hailort/build/hailort/libhailort/src/
-RUN ls -ahl /opt/hailort/hailort/libhailort/bindings/python/platform/hailo_platform/pyhailort/
-
-# Remove the existing setup.py if it exists in the target directory
-RUN rm -f /opt/hailort/hailort/libhailort/bindings/python/platform/setup.py
-
-# Copy generate_wheel_conf.py and setup.py
-COPY docker/hailo8l/pyhailort_build_scripts/generate_wheel_conf.py /opt/hailort/hailort/libhailort/bindings/python/platform/generate_wheel_conf.py
-COPY docker/hailo8l/pyhailort_build_scripts/setup.py /opt/hailort/hailort/libhailort/bindings/python/platform/setup.py
-
-# Run the generate_wheel_conf.py script
-RUN python3 /opt/hailort/hailort/libhailort/bindings/python/platform/generate_wheel_conf.py
+ cmake --build build --config release --target hailortcli && \
+ cmake --build build --config release --target install
# Create a wheel file using pip3 wheel
RUN cd /opt/hailort/hailort/libhailort/bindings/python/platform && \
python3 setup.py bdist_wheel --dist-dir /hailo-wheels
+RUN mkdir -p /rootfs/usr/local/lib /rootfs/usr/local/bin && \
+ cp /usr/local/lib/libhailort.so* /rootfs/usr/local/lib && \
+ cp /usr/local/bin/hailortcli /rootfs/usr/local/bin
+
# Use deps as the base image
FROM deps AS h8l-frigate
+ARG HAILO_VERSION
# Copy the wheels from the wheels stage
COPY --from=h8l-wheels /h8l-wheels /deps/h8l-wheels
COPY --from=build-hailort /hailo-wheels /deps/hailo-wheels
-COPY --from=build-hailort /etc/environment /etc/environment
-RUN CC=$(python3 -c "import sysconfig; import shlex; cc = sysconfig.get_config_var('CC'); cc_cmd = shlex.split(cc)[0]; print(cc_cmd[:-4] if cc_cmd.endswith('-gcc') else cc_cmd)") && \
- echo "CC=$CC" >> /etc/environment
+COPY --from=build-hailort /rootfs/ /
# Install the wheels
RUN pip3 install -U /deps/h8l-wheels/*.whl
RUN pip3 install -U /deps/hailo-wheels/*.whl
-RUN . /etc/environment && \
- mv /usr/local/lib/python${PYTHON_VERSION}/dist-packages/hailo_platform/pyhailort/libhailort.so /usr/lib/${CC} && \
- cd /usr/lib/${CC}/ && \
- ln -s libhailort.so libhailort.so.4.18.0
-
# Copy base files from the rootfs stage
COPY --from=rootfs / /
-# Set environment variables for Hailo SDK
-ENV PATH="/opt/hailort/bin:${PATH}"
-ENV LD_LIBRARY_PATH="/usr/lib/$(if [ $TARGETARCH == "amd64" ]; then echo 'x86_64'; else echo 'aarch64'; fi )-linux-gnu:${LD_LIBRARY_PATH}"
-
# Set workdir
WORKDIR /opt/frigate/
diff --git a/docker/hailo8l/pyhailort_build_scripts/generate_wheel_conf.py b/docker/hailo8l/pyhailort_build_scripts/generate_wheel_conf.py
deleted file mode 100644
index a0e4987f16..0000000000
--- a/docker/hailo8l/pyhailort_build_scripts/generate_wheel_conf.py
+++ /dev/null
@@ -1,67 +0,0 @@
-import json
-import os
-import platform
-import sys
-import sysconfig
-
-
-def extract_toolchain_info(compiler):
- # Remove the "-gcc" or "-g++" suffix if present
- if compiler.endswith("-gcc") or compiler.endswith("-g++"):
- compiler = compiler.rsplit("-", 1)[0]
-
- # Extract the toolchain and ABI part (e.g., "gnu")
- toolchain_parts = compiler.split("-")
- abi_conventions = next(
- (part for part in toolchain_parts if part in ["gnu", "musl", "eabi", "uclibc"]),
- "",
- )
-
- return abi_conventions
-
-
-def generate_wheel_conf():
- conf_file_path = os.path.join(
- os.path.abspath(os.path.dirname(__file__)), "wheel_conf.json"
- )
-
- # Extract current system and Python version information
- py_version = f"cp{sys.version_info.major}{sys.version_info.minor}"
- arch = platform.machine()
- system = platform.system().lower()
- libc_version = platform.libc_ver()[1]
-
- # Get the compiler information
- compiler = sysconfig.get_config_var("CC")
- abi_conventions = extract_toolchain_info(compiler)
-
- # Create the new configuration data
- new_conf_data = {
- "py_version": py_version,
- "arch": arch,
- "system": system,
- "libc_version": libc_version,
- "abi": abi_conventions,
- "extension": {
- "posix": "so",
- "nt": "pyd", # Windows
- }[os.name],
- }
-
- # If the file exists, load the existing data
- if os.path.isfile(conf_file_path):
- with open(conf_file_path, "r") as conf_file:
- conf_data = json.load(conf_file)
- # Update the existing data with the new data
- conf_data.update(new_conf_data)
- else:
- # If the file does not exist, use the new data
- conf_data = new_conf_data
-
- # Write the updated data to the file
- with open(conf_file_path, "w") as conf_file:
- json.dump(conf_data, conf_file, indent=4)
-
-
-if __name__ == "__main__":
- generate_wheel_conf()
diff --git a/docker/hailo8l/pyhailort_build_scripts/setup.py b/docker/hailo8l/pyhailort_build_scripts/setup.py
deleted file mode 100644
index 2abe07ee5f..0000000000
--- a/docker/hailo8l/pyhailort_build_scripts/setup.py
+++ /dev/null
@@ -1,111 +0,0 @@
-import json
-import os
-
-from setuptools import find_packages, setup
-from wheel.bdist_wheel import bdist_wheel as orig_bdist_wheel
-
-
-class NonPurePythonBDistWheel(orig_bdist_wheel):
- """Makes the wheel platform-dependent so it can be based on the _pyhailort architecture"""
-
- def finalize_options(self):
- orig_bdist_wheel.finalize_options(self)
- self.root_is_pure = False
-
-
-def _get_hailort_lib_path():
- lib_filename = "libhailort.so"
- lib_path = os.path.join(
- os.path.abspath(os.path.dirname(__file__)),
- f"hailo_platform/pyhailort/{lib_filename}",
- )
- if os.path.exists(lib_path):
- print(f"Found libhailort shared library at: {lib_path}")
- else:
- print(f"Error: libhailort shared library not found at: {lib_path}")
- raise FileNotFoundError(f"libhailort shared library not found at: {lib_path}")
- return lib_path
-
-
-def _get_pyhailort_lib_path():
- conf_file_path = os.path.join(
- os.path.abspath(os.path.dirname(__file__)), "wheel_conf.json"
- )
- if not os.path.isfile(conf_file_path):
- raise FileNotFoundError(f"Configuration file not found: {conf_file_path}")
-
- with open(conf_file_path, "r") as conf_file:
- content = json.load(conf_file)
- py_version = content["py_version"]
- arch = content["arch"]
- system = content["system"]
- extension = content["extension"]
- abi = content["abi"]
-
- # Construct the filename directly
- lib_filename = f"_pyhailort.cpython-{py_version.split('cp')[1]}-{arch}-{system}-{abi}.{extension}"
- lib_path = os.path.join(
- os.path.abspath(os.path.dirname(__file__)),
- f"hailo_platform/pyhailort/{lib_filename}",
- )
-
- if os.path.exists(lib_path):
- print(f"Found _pyhailort shared library at: {lib_path}")
- else:
- print(f"Error: _pyhailort shared library not found at: {lib_path}")
- raise FileNotFoundError(
- f"_pyhailort shared library not found at: {lib_path}"
- )
-
- return lib_path
-
-
-def _get_package_paths():
- packages = []
- pyhailort_lib = _get_pyhailort_lib_path()
- hailort_lib = _get_hailort_lib_path()
- if pyhailort_lib:
- packages.append(pyhailort_lib)
- if hailort_lib:
- packages.append(hailort_lib)
- packages.append(os.path.abspath("hailo_tutorials/notebooks/*"))
- packages.append(os.path.abspath("hailo_tutorials/hefs/*"))
- return packages
-
-
-if __name__ == "__main__":
- setup(
- author="Hailo team",
- author_email="[email protected]",
- cmdclass={
- "bdist_wheel": NonPurePythonBDistWheel,
- },
- description="HailoRT",
- entry_points={
- "console_scripts": [
- "hailo=hailo_platform.tools.hailocli.main:main",
- ]
- },
- install_requires=[
- "argcomplete",
- "contextlib2",
- "future",
- "netaddr",
- "netifaces",
- "verboselogs",
- "numpy==1.23.3",
- ],
- name="hailort",
- package_data={
- "hailo_platform": _get_package_paths(),
- },
- packages=find_packages(),
- platforms=[
- "linux_x86_64",
- "linux_aarch64",
- "win_amd64",
- ],
- url="https://hailo.ai/",
- version="4.17.0",
- zip_safe=False,
- )
diff --git a/docker/hailo8l/user_installation.sh b/docker/hailo8l/user_installation.sh
index 853652ffa1..2cf44126f2 100644
--- a/docker/hailo8l/user_installation.sh
+++ b/docker/hailo8l/user_installation.sh
@@ -13,7 +13,7 @@ else
fi
# Clone the HailoRT driver repository
-git clone --depth 1 --branch v4.18.0 https://github.com/hailo-ai/hailort-drivers.git
+git clone --depth 1 --branch v4.19.0 https://github.com/hailo-ai/hailort-drivers.git
# Build and install the HailoRT driver
cd hailort-drivers/linux/pcie
@@ -38,7 +38,7 @@ cd ../../
if [ ! -d /lib/firmware/hailo ]; then
sudo mkdir /lib/firmware/hailo
fi
-sudo mv hailo8_fw.4.18.0.bin /lib/firmware/hailo/hailo8_fw.bin
+sudo mv hailo8_fw.*.bin /lib/firmware/hailo/hailo8_fw.bin
# Install udev rules
sudo cp ./linux/pcie/51-hailo-udev.rules /etc/udev/rules.d/