Skip to content

BuildingCode

Tatiana Savina edited this page Dec 14, 2021 · 22 revisions

Build OpenVINO™ Inference Engine

Contents

Introduction

The Inference Engine can infer models in different formats with various input and output formats.

The open source version of Inference Engine includes the following plugins:

PLUGIN DEVICE TYPES
CPU plugin Intel® Xeon® with Intel® AVX2 and AVX512, Intel® Core™ Processors with Intel® AVX2, Intel® Atom® Processors with Intel® SSE
GPU plugin Intel® Processor Graphics, including Intel® HD Graphics and Intel® Iris® Graphics
GNA plugin Intel® Speech Enabling Developer Kit, Amazon Alexa* Premium Far-Field Developer Kit, Intel® Pentium® Silver processor J5005, Intel® Celeron® processor J4005, Intel® Core™ i3-8121U processor
MYRIAD plugin Intel® Neural Compute Stick 2 powered by the Intel® Movidius™ Myriad™ X
Heterogeneous plugin Heterogeneous plugin enables computing for inference on one network on several Intel® devices.
MULTI plugin Automatic inference on multiple devices simultaneously
AUTO plugin Automatic device selection

Building for different OSes

NOTE: Please, refer to a dedicated guide with CMake options which control OpenVINO build if you need a custom build.

Building in a Docker image

You can also build Intel® Distribution of OpenVINO™ toolkit in a Docker image by following this guide.

Installing

Once project is built you can install OpenVINO™ Inference Engine into custom location:

cmake --install . --prefix <INSTALLDIR>

Checking your installation:

  1. Obtaining Open Moldel Zoo tools and models

To have ability run samples and demo you need to clone Open Model Zoo repository and copy folder under ./deployment_tools in your install directory:

git clone https://github.com/openvinotoolkit/open_model_zoo.git
cmake -E copy_directory ./open_model_zoo/ <INSTALLDIR>/deployment_tools/open_model_zoo/
  1. Adding OpenCV to your environment

You can find more info on OpenCV custom builds here.

Open Model Zoo samples use OpenCV functionality to load images, so to use it for demo builds you need to provide path to your OpenCV custom build by setting OpenCV_DIR environment variable and add path OpenCV libraries to LD_LIBRARY_PATH (Linux*) or PATH (Windows*) variable before running demos.

Linux:

export LD_LIBRARY_PATH=/path/to/opencv_install/lib/:$LD_LIBRARY_PATH
export OpenCV_DIR=/path/to/opencv_install/cmake

Windows:

set PATH=/path/to/opencv_install/bin/;%PATH%
set OpenCV_DIR=/path/to/opencv_install/cmake
  1. Running demo

To check your installation go to the demo directory and run Classification Demo:

Linux:

cd <INSTALLDIR>/deployment_tools/demo
./demo_squeezenet_download_convert_run.sh

Windows:

cd <INSTALLDIR>\deployment_tools\demo
demo_squeezenet_download_convert_run.bat
Result:

Top 10 results:

Image <INSTALLDIR>/deployment_tools/demo/car.png

classid probability label
------- ----------- -----
817     0.6853030   sports car, sport car
479     0.1835197   car wheel
511     0.0917197   convertible
436     0.0200694   beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon
751     0.0069604   racer, race car, racing car
656     0.0044177   minivan
717     0.0024739   pickup, pickup truck
581     0.0017788   grille, radiator grille
468     0.0013083   cab, hack, taxi, taxicab
661     0.0007443   Model T

[ INFO ] Execution successful

Use Custom OpenCV Builds for Inference Engine

NOTE: The recommended and tested version of OpenCV is 4.4.0.

Required versions of OpenCV packages are downloaded automatically during the building Inference Engine library. If the build script can not find and download the OpenCV package that is supported on your platform, you can use one of the following options:

  • Download the most suitable version from the list of available pre-build packages from https://download.01.org/opencv/2020/openvinotoolkit from the <release_version>/inference_engine directory.

  • Use a system-provided OpenCV package (e.g with running the apt install libopencv-dev command). The following modules must be enabled: imgcodecs, videoio, highgui.

  • Get the OpenCV package using a package manager: pip, conda, conan etc. The package must have the development components included (header files and CMake scripts).

  • Build OpenCV from source using the build instructions on the OpenCV site.

After you got the built OpenCV library, perform the following preparation steps before running the Inference Engine build:

  1. Set the OpenCV_DIR environment variable to the directory where the OpenCVConfig.cmake file of you custom OpenCV build is located.
  2. Disable the package automatic downloading with using the -DENABLE_OPENCV=OFF option for CMake-based build script for Inference Engine.

Add Inference Engine to Your Project

For CMake projects, set the InferenceEngine_DIR when you run CMake tool:

cmake -DInferenceEngine_DIR=/path/to/openvino/build/ .

Then you can find Inference Engine by find_package:

find_package(InferenceEngine REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE ${InferenceEngine_LIBRARIES})

Next Steps

Congratulations, you have built the Inference Engine. To get started with the OpenVINO™, proceed to the Get Started guides:

Additional Resources


* Other names and brands may be claimed as the property of others.

Clone this wiki locally