Skip to content

BuildingForLinux

Valentina edited this page Nov 9, 2023 · 47 revisions

Building for Linux

To install software requirements, please follow instructions. This manual is for Ubuntu 20.04, for other OS it may be different.

DLI supports several inference frameworks:

Common pre-requisites

  1. Install Python tools (Python 3.8 is already installed by default in Ubuntu 20.04).

    sudo apt install python3-pip python3-venv python3-tk
  2. Create and activate virtual environment.

    cd ~/
    python3 -m venv dl-benchmark-env
    source ~/dl-benchmark-env/bin/activate
    python3 -m pip install --upgrade pip
  3. Clone repository.

    sudo apt install git
    git clone https://github.com/itlab-vision/dl-benchmark.git
  4. Install requirements.

    pip install -r ~/dl-benchmark/requirements.txt

OpenVINO toolkit pre-requisites

Python API

If you would like to infer deep models using the Intel® Distribution of OpenVINO™ Toolkit (Python API), please, install openvino-dev package using pip.

pip install openvino-dev[caffe,mxnet,onnx,pytorch,tensorflow]==2022.1.0

Note: there is no way to install tensorflow and tensorflow2 packages to the single virtual environment, so to convert tensorflow2 models, please, create another virtual environment and install openvino-dev package with the support of tensorflow2:

pip install openvino-dev[tensorflow2]==2022.1.0

Note: please, set the OpenVINO version instead of 2022.1.0.

C++ API

If you would like to infer deep models using the Intel® Distribution of OpenVINO™ Toolkit (C++ API), please, install the OpenVINO toolkit from sources or download pre-built package and follow Benchmark C++ tool build instructions to get OpenVINO C++ benchmark app built.

Intel-caffe pre-requisites

If you prefer Intel® Optimization for Caffe to infer deep neural networks, please, install Miniconda or Anaconda and corresponding package intel-caffe.

conda install caffe

Intel-tensorflow pre-requisites

If you would like to infer deep models using the Intel® Optimization for TensorFlow, please, install package intel-tensorflow using pip.

pip install intel-tensorflow

TensorFlow lite pre-requisites

Python API

To infer deep learning models using the TensorFlow lite framework please install tensorflow python package.

pip install tensorflow

C++ API

TensorFlow lite CPP requires to be built from sources along with dedicated benchmark tool. Please refer to build instruction to build binaries.

ONNX Runtime pre-requisites

Python API

To infer deep learning models using ONNX Runtime (Python API), please, install the corresponding package.

pip install onnxruntime

C++ API

ONNX Runtime requires to be built from sources along with dedicated benchmark tool. Please refer to build instruction to build binaries.

MXNet pre-requisites

Python API

If you would like to infer deep models using MXNet please install mxnet python package.

pip install mxnet

OpenCV DNN pre-requisites

Python API

To use OpenCV DNN backend inferring deep models, please, install the opencv-python package.

pip install opencv-python

To use the OpenVINO Inference Engine backend, please, install the openvino and openvino-dev Python packages and build OpenCV from sources. Set WITH_OPENVINO option executing cmake. The sequence of required instructions is represented below. Don't foget to update environment variables.

OCV_VERSION=4.7.0
git clone --recurse-submodules https://github.com/opencv/opencv.git \
          --depth 1 --branch ${OCV_VERSION} --single-branch
OpenCV_BUILD_DIR=build-opencv
mkdir $OpenCV_BUILD_DIR
cd $OpenCV_BUILD_DIR
cmake -G Ninja \
  -D CMAKE_INSTALL_PREFIX=install \
  -D CMAKE_BUILD_TYPE=Release \
  -D BUILD_EXAMPLES=OFF \
  -D BUILD_TESTS=OFF \
  -D BUILD_DOCS=OFF \
  -D WITH_OPENVINO=ON \
  -D OPENCV_LIB_INSTALL_PATH=lib \
  -D OPENCV_CONFIG_INSTALL_PATH=cmake \
  -D PYTHON3_PACKAGES_PATH=install/python/python3 \
  ./opencv && ninja && cmake --install .'
OpenCV_INSTALL_DIR="$OpenCV_BUILD_DIR/install"
OpenCV_DIR="$OpenCV_INSTALL_DIR/cmake"
LD_LIBRARY_PATH="$OpenCV_INSTALL_DIR/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
PYTHONPATH="$OpenCV_INSTALL_DIR/python/python3/cv2/python-3.8${PYTHONPATH:+:$PYTHONPATH}"

Note: please, set the OpenCV version instead of 4.7.0.

C++ API

OpenCV DNN CPP requires to be built from sources along with dedicated benchmark tool. Please refer to build instruction to build binaries.

PyTorch pre-requisites

Python API

To infer deep learning models using PyTorch, please, install the following packages:

pip install torch torchvision torchaudio

C++ API

PyTorch CPP requires to be built from sources along with dedicated benchmark tool. Please refer to build instruction to build binaries.

Clone this wiki locally