Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: I am trying to build and test openvino on WasmEdge but it is failing? #18517

Closed
Mash707 opened this issue Jul 12, 2023 · 26 comments · Fixed by #18558
Closed

Problem: I am trying to build and test openvino on WasmEdge but it is failing? #18517

Mash707 opened this issue Jul 12, 2023 · 26 comments · Fixed by #18558
Assignees
Labels
category: build OpenVINO cmake script / infra support_request
Milestone

Comments

@Mash707
Copy link

Mash707 commented Jul 12, 2023

  export OpenVINO_DIR=/usr/lib/x86_64-linux-gnu/cmake/openvino202[3](https://github.com/WasmEdge/WasmEdge/actions/runs/5511277380/jobs/10046621552?pr=2636#step:5:3).0.1
  ldconfig
  plugin_array=(${tar_names})
  option_array=(${build_options})
  cmake -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_BUILD_TESTS=ON -DWASMEDGE_BUILD_AOT_RUNTIME=OFF -DWASMEDGE_BUILD_TOOLS=OFF
  
  for (( i=0; i<${#plugin_array[@]}; i++ ));
  do
    echo "Building ${plugin_array[$i]} backend:"
    cmake -Bbuild -GNinja ${option_array[$i]}
    cmake --build build --target ${test_bin}
  
    echo "Testing ${plugin_array[$i]} backend:"
    cd ${test_dir}
    ./${test_bin}
    cd -
  
    echo "Copying ${plugin_array[$i]} backend:"
    cp -f ${output_dir}/${output_bin} ${output_bin}
    tar -zcvf plugin_${plugin_array[$i]}.tar.gz ${output_bin}
  done```
 
This is the script I am running 
@Mash707
Copy link
Author

Mash707 commented Jul 12, 2023

I am getting the following error

CMake Error at /usr/share/cmake-3.22/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
  Could not find a package configuration file provided by "OpenVINO" with any
  of the following names:

    OpenVINOConfig.cmake
    openvino-config.cmake

  Add the installation prefix of "OpenVINO" to CMAKE_PREFIX_PATH or set
  "OpenVINO_DIR" to a directory containing one of the above files.  If
  "OpenVINO" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  /usr/lib/x86_64-linux-gnu/cmake/inferenceengine2023.0.1/InferenceEngineConfig.cmake:72 (find_dependency)
  cmake/WASINNDeps.cmake:150 (find_package)
  test/plugins/wasi_nn/CMakeLists.txt:67 (wasmedge_setup_wasinn_target)


-- Configuring incomplete, errors occurred!
See also "/__w/WasmEdge/WasmEdge/build/CMakeFiles/CMakeOutput.log".
Error: Process completed with exit code 1.```

@Mash707 Mash707 changed the title Question: I am trying to build and test openvino on WasmEdge but it is failing? Problem: I am trying to build and test openvino on WasmEdge but it is failing? Jul 12, 2023
@riverlijunjie
Copy link
Contributor

Could you confirm where openvino is installed in your machine and set correct OpenVINO_DIR?

@Mash707
Copy link
Author

Mash707 commented Jul 13, 2023

I am using docker to test the installation script. The path to the OpenVINOConfig.cmake according to the docker image is /usr/lib/x86_64-linux-gnu/cmake/openvino2023.0.1/OpenVINOConfig.cmake

I am installing it on linux using the apt method and having ubuntu 20.04 as the base image.

@avitial avitial added category: build OpenVINO cmake script / infra support_request labels Jul 13, 2023
@riverlijunjie
Copy link
Contributor

After openvino is installed, you can see a script named setupvars.sh in installation directory, which can setup openvino's environment, could you have a try?

image

@Mash707
Copy link
Author

Mash707 commented Jul 14, 2023

setupvars.sh does not exist in the installation directory . I ran the container and searched for it through the terminal.
image
I am sharing my Dockerfile , please tell if something is wrong in the installation script

RUN apt-get -y update
RUN apt-get install -y wget 
RUN apt-get install -y apt-transport-https 
RUN apt-get install -y gnupg
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# SPDX-FileCopyrightText: 2019-2022 Second State INC

RUN set -e
RUN echo "Installing OpenVINO with version 2023.0.1"
RUN wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
RUN apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
RUN echo "deb https://apt.repos.intel.com/openvino/2023 ubuntu20 main" | tee /etc/apt/sources.list.d/intel-openvino-2023.list
RUN apt update
RUN apt install -y openvino
RUN ldconfig

@Mash707
Copy link
Author

Mash707 commented Jul 14, 2023

@ilya-lavrenov
Copy link
Contributor

@Mash707 could you please try to run samples build using /usr/share/openvino/samples/cpp/build_samples.sh ? Does it pass?
It relies on OpenVINOConfig.cmake located in /usr/lib/x86_64-linux-gnu/cmake/openvino2023.0.1

@Mash707
Copy link
Author

Mash707 commented Jul 14, 2023

@ilya-lavrenov Yes the build is working
image

@ilya-lavrenov
Copy link
Contributor

@Mash707
As far as I can see from the logs, you are using find_package(InferenceEngine) instead of find_package(OpenVINO) (used by our samples scripts). Could you please try to find OpenVINO?

InferenceEngineConfig will be removed in 2024 release and OpenVINOConfig.cmake is suggested for usage.
Meanwhile, I will try InferenceEngineConfig.cmake on my side to check whether it's broken or not (all our scripts have already migrated to OpenVINOConfig.cmake)

@Mash707
Copy link
Author

Mash707 commented Jul 14, 2023

@ilya-lavrenov I will try to find OpenVINO.
You can also have a look at my PR for the files I have changed WasmEdge/WasmEdge#2636

@Mash707
Copy link
Author

Mash707 commented Jul 14, 2023

I found out the script that you may be referring to
image
Do you mean this only ?
This is the link to the file in the official repo https://github.com/WasmEdge/WasmEdge/blob/a97f4caeb2c4f3832bf2127be09ca974d8ce8f51/cmake/WASINNDeps.cmake#L150

@ilya-lavrenov
Copy link
Contributor

Yes, this place.

@Mash707
Copy link
Author

Mash707 commented Jul 14, 2023

So I have to change it from InferenceEngine to OpenVINO to fix the issue?

@ilya-lavrenov
Copy link
Contributor

I have not tried, but since OpenVINOConfig.cmake works - let's try to find it instead of legacy InferenceEngineConfig.cmake

@Mash707
Copy link
Author

Mash707 commented Jul 14, 2023

@ilya-lavrenov
Copy link
Contributor

How have you modified cmake ?
I suppose you have included only openvino::runtime::c as a dependency? If yes, please, include openvino::runtime as well

@Mash707
Copy link
Author

Mash707 commented Jul 14, 2023

The changes I made were replacing InferenceEngine with Openvino.
I have shared the file with the changes I made

  # Add backends building flags.
  foreach(BACKEND ${WASMEDGE_PLUGIN_WASI_NN_BACKEND})
    string(TOLOWER ${BACKEND} BACKEND)
    if(BACKEND STREQUAL "openvino")
      message(STATUS "WASI-NN: Build OpenVINO backend for WASI-NN")
      find_package(OpenVINO REQUIRED)
      add_definitions(-DWASMEDGE_PLUGIN_WASI_NN_BACKEND_OPENVINO)
      list(APPEND WASMEDGE_PLUGIN_WASI_NN_DEPS
        ${OpenVINO_LIBRARIES}
      )
    elseif(BACKEND STREQUAL "pytorch")
      message(STATUS "WASI-NN: Build PyTorch backend for WASI-NN")
      find_package(Torch REQUIRED)
      add_definitions(-DWASMEDGE_PLUGIN_WASI_NN_BACKEND_TORCH)
      list(APPEND WASMEDGE_PLUGIN_WASI_NN_DEPS
        ${TORCH_LIBRARIES}
      )
    elseif(BACKEND STREQUAL "tensorflowlite")
      message(STATUS "WASI-NN: Build Tensorflow lite backend for WASI-NN")
      add_definitions(-DWASMEDGE_PLUGIN_WASI_NN_BACKEND_TFLITE)
      wasmedge_setup_tf_headers()
      list(APPEND WASMEDGE_PLUGIN_WASI_NN_INCLUDES
        ${WASMEDGE_TENSORFLOW_DEPS_HEADERS}
      )
      wasmedge_setup_tflite_lib()
      list(APPEND WASMEDGE_PLUGIN_WASI_NN_DEPS
        ${WASMEDGE_TENSORFLOW_DEPS_TFLITE_LIB}
      )
    else()
      # Add the other backends here.
      message(FATAL_ERROR "WASI-NN: backend ${BACKEND} not found or unimplemented.")
    endif()
  endforeach()

  target_include_directories(${target}
    PUBLIC
    ${WASMEDGE_PLUGIN_WASI_NN_INCLUDES}
  )
  target_link_libraries(${target}
    PUBLIC
    ${WASMEDGE_PLUGIN_WASI_NN_DEPS}
  )
endfunction()

function(wasmedge_setup_tf_target target)
  wasmedge_setup_tf_headers()
  wasmedge_setup_tf_lib()
  target_include_directories(${target}
    PUBLIC
    ${WASMEDGE_TENSORFLOW_DEPS_HEADERS}
  )
  target_link_libraries(${target}
    PUBLIC
    ${WASMEDGE_TENSORFLOW_DEPS_TF_LIB}
  )
endfunction()

function(wasmedge_setup_tflite_target target)
  wasmedge_setup_tf_headers()
  wasmedge_setup_tflite_lib()
  target_include_directories(${target}
    PUBLIC
    ${WASMEDGE_TENSORFLOW_DEPS_HEADERS}
  )
  target_link_libraries(${target}
    PUBLIC
    ${WASMEDGE_TENSORFLOW_DEPS_TFLITE_LIB}
  )
endfunction()

@ilya-lavrenov
Copy link
Contributor

OpenVINO_LIBRARIES is not available.
Users have to use explicitly imported targets like openvino::runtime, openvino::runtime::c and others.

Please, have a look what OpenVINOConfig.cmake provides https://github.com/openvinotoolkit/openvino/blob/master/cmake/templates/OpenVINOConfig.cmake.in#L1-L94C1

@Mash707
Copy link
Author

Mash707 commented Jul 14, 2023

Sorry Could you tell how one can import targets? (ps - I am new to open source and this is my first issue so its little bit confusing for me)

@ilya-lavrenov
Copy link
Contributor

They are already imported.
Just use openvino::runtime openvino::runtime::c instead of OpenVINO_LIBRARIES

@Mash707
Copy link
Author

Mash707 commented Jul 14, 2023

Do you mean like this? target_link_libraries(${target} PRIVATE openvino::runtime openvino::runtime::c)
I am bit confused in syntax on how do I apply that

Sorry if I am asking silly questions

@Mash707
Copy link
Author

Mash707 commented Jul 14, 2023

@ilya-lavrenov Update: Everything is working fine now. Thank you so much.
These were the changes I made and it worked

  # Add backends building flags.
  foreach(BACKEND ${WASMEDGE_PLUGIN_WASI_NN_BACKEND})
    string(TOLOWER ${BACKEND} BACKEND)
    if(BACKEND STREQUAL "openvino")
      message(STATUS "WASI-NN: Build OpenVINO backend for WASI-NN")
      find_package(OpenVINO REQUIRED)
      add_definitions(-DWASMEDGE_PLUGIN_WASI_NN_BACKEND_OPENVINO)
      target_link_libraries(${target} PRIVATE openvino::runtime openvino::runtime::c)
      list(APPEND WASMEDGE_PLUGIN_WASI_NN_DEPS
        openvino::runtime openvino::runtime::c
      )```

@ilya-lavrenov
Copy link
Contributor

    if(BACKEND STREQUAL "openvino")
      message(STATUS "WASI-NN: Build OpenVINO backend for WASI-NN")
      find_package(OpenVINO REQUIRED)
      add_definitions(-DWASMEDGE_PLUGIN_WASI_NN_BACKEND_OPENVINO)
      list(APPEND WASMEDGE_PLUGIN_WASI_NN_DEPS
        openvino::runtime openvino::runtime::c
      )

@Mash707
Copy link
Author

Mash707 commented Jul 14, 2023

@ilya-lavrenov just a off topic question . I would love to contribute to the openvino repo. What are the prerequisites I need to know ? I am a complete beginner.
Also do you guys have a slack/discord channel which I can join?

@ilya-lavrenov
Copy link
Contributor

@ilya-lavrenov just a off topic question . I would love to contribute to the openvino repo. What are the prerequisites I need to know ? I am a complete beginner. Also do you guys have a slack/discord channel which I can join?

We have a list of tasks which can be taken on by external developers #17502

Also do you guys have a slack/discord channel which I can join?

We have no slack/discord channels

@Mash707
Copy link
Author

Mash707 commented Jul 14, 2023

Thank you . I will see if I can contribute something.

@ilya-lavrenov ilya-lavrenov added this to the 2023.1 milestone Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: build OpenVINO cmake script / infra support_request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants