From 9956cda1916d4ad4576e53b88539d26a9c4db73c Mon Sep 17 00:00:00 2001 From: Will French Date: Fri, 24 Jan 2025 14:11:46 -0600 Subject: [PATCH] Update cmake build to use system deps and standard install paths (#8) * Update cmake build to use system deps and standard install paths * Use edge channel where gimp plugin snap with updated command-chain is published --- .gitignore | 3 +++ checkbox/bin/install-full-deps | 2 +- command-chain/openvino-launch | 16 +++++---------- sample-consumer/snap/snapcraft.yaml | 3 ++- snap/snapcraft.yaml | 31 +++++++++++++++++++---------- 5 files changed, 32 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index d294450..9c38422 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ +# Snap build artifacts *.snap +# logs from snapcraft remote-build +*.txt diff --git a/checkbox/bin/install-full-deps b/checkbox/bin/install-full-deps index 22c7b36..23171ca 100755 --- a/checkbox/bin/install-full-deps +++ b/checkbox/bin/install-full-deps @@ -23,7 +23,7 @@ fi sudo DEBIAN_FRONTEND=noninteractive apt install -y intel-gpu-tools jq sudo snap install intel-npu-driver --beta -sudo snap install openvino-ai-plugins-gimp --beta +sudo snap install openvino-ai-plugins-gimp --edge # the content interfaces require manual connection sudo snap connect openvino-sample-consumer:npu-libs intel-npu-driver:npu-libs diff --git a/command-chain/openvino-launch b/command-chain/openvino-launch index b334dc4..d837c1c 100755 --- a/command-chain/openvino-launch +++ b/command-chain/openvino-launch @@ -7,18 +7,12 @@ # and emits a warning if a node is inaccessible. # -# Save positional args in a new variable as setupvars.sh consumes $@ -cmd=("$@") - -# Source OpenVINO script to export environment vars needed at runtime -if [ -f "${SNAP}/openvino/usr/setupvars.sh" ]; then - source "${SNAP}/openvino/usr/setupvars.sh" -else - echo "Warning: OpenVINO command-chain script not found." +CONTENT_PATH="${SNAP}/openvino" +if [ ! -d "${CONTENT_PATH}" ]; then + echo "Warning: ${CONTENT_PATH} not present inside ${SNAP_NAME} snap. Please connect the content interface at this path." fi - -# libOpenCL shared objects distributed with OpenVINO snap export LD_LIBRARY_PATH="${SNAP}/openvino/usr/lib/x86_64-linux-gnu":$LD_LIBRARY_PATH +export PYTHONPATH="${SNAP}/openvino/usr/lib/python3/dist-packages":$PYTHONPATH # Check user access to Intel accelerator devices (GPU and NPU) check_user_access() { @@ -53,4 +47,4 @@ check_user_access() { check_user_access GPU /dev/dri/render render check_user_access NPU /dev/accel/accel render -exec "${cmd[@]}" +exec "$@" diff --git a/sample-consumer/snap/snapcraft.yaml b/sample-consumer/snap/snapcraft.yaml index e034180..5f37f0c 100644 --- a/sample-consumer/snap/snapcraft.yaml +++ b/sample-consumer/snap/snapcraft.yaml @@ -124,7 +124,8 @@ parts: plugin: dump source-type: git source: https://github.com/canonical/openvino-toolkit-snap.git - source-tag: 2024.6.0-0 + source-branch: frenchwr/cmake-best-practices + #source-tag: 2024.6.0-0 stage: - command-chain/openvino-launch diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 04ef480..84a15fe 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -10,7 +10,6 @@ adopt-info: openvino platforms: arm64: - build-on: [amd64] amd64: # the recommended mountpoint for the content is /openvino @@ -31,10 +30,19 @@ parts: - -DENABLE_PYTHON=ON - -DPython3_EXECUTABLE=/usr/bin/python3.12 - -DCMAKE_INSTALL_PREFIX=/usr + - -DENABLE_SYSTEM_TBB=ON + - -DENABLE_SYSTEM_SNAPPY=ON + - -DENABLE_SNAPPY_COMPRESSION=ON + - -DCPACK_GENERATOR=DEB + - -DENABLE_SAMPLES=OFF + - -DENABLE_PYTHON_PACKAGING=ON override-pull: | craftctl default git submodule update --init --recursive craftctl set version="$(git describe --tags)" + override-build: | + craftctl default + rm -rf ${CRAFT_PART_INSTALL}/usr/{share,include,bin} build-packages: - ca-certificates - file @@ -42,8 +50,6 @@ parts: - ninja-build - scons - ccache - - gcc-multilib - - g++-multilib - pkgconf - git - shellcheck @@ -66,16 +72,21 @@ parts: - libffi-dev - python3-enchant - wget + - libsnappy-dev stage-packages: - ocl-icd-libopencl1 + - libtbb12 + - libsnappy1v5 lint: ignore: - library: - # These are needed but are flagged - # by the linter because they are not - # explicitly linked to any binary or - # shared object - - usr/runtime/3rdparty/tbb/lib/libtbbbind* - - usr/runtime/3rdparty/tbb/lib/libtbbmalloc* - - usr/runtime/3rdparty/tbb/lib/libhwloc.so.15.6.4 \ No newline at end of file + # OpenVINO libs consumed by other snaps + - usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/libopenvino* + # Linked by libopenvino_tensorflow_frontend + - usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/libsnappy* + # Not explicitly linked but dlopen'd + - usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/libtbbbind* + - usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/libtbbmalloc* + # Linked by libtbbbind + - usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/libhwloc* \ No newline at end of file