Skip to content

BuildingForLinux

Valentina edited this page Dec 10, 2024 · 46 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.

Сaffe pre-requisites

If you prefer Caffe to infer deep neural networks, please, install Miniconda or Anaconda and corresponding package caffe.

conda install caffe

Note: Caffe requires Python <=3.7.

TensorFlow pre-requisites

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

pip install 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.

DGL pre-requisites

Python API

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

pip install  dgl -f https://data.dgl.ai/wheels/torch-2.1/repo.html

Note: if you have installed dgl-cuXX package, please uninstall it first.

Spektral pre-requisites

Python API

If you would like to infer deep models using Spektral, please, install the package spektral using pip.

pip install spektral

RKNN pre-requisites

C++ API

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

ncnn pre-requisites

Python API

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

pip install ncnn

Apache TVM pre-requisites

Python API

To infer deep learning models using Apache TVM, please, install the following package:

pip install apache-tvm

Notes:

  1. If you would like to infer Caffe, MXNet, PyTorch, TensorFlow Lite or ONNX models directly or convert these models to the TVM format, please, install the corresponding framework.
  2. If you would like to infer TensorFlow models, please, convert these models to the ONNX format using tf2onnx according to the recommendations of Apache TVM developers.

PaddlePaddle pre-requisites

Python API

To infer deep learning models using PaddlePaddle, please, install the following packages.

Command to install CPU version:

python -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple

or

python -m pip install paddlepaddle -i https://pypi.tuna.tsinghua.edu.cn/simple

If you only want to install GPU version, please refer the command below.

python -m pip install paddlepaddle-gpu -i https://mirror.baidu.com/pypi/simple

or

python -m pip install paddlepaddle-gpu -i https://pypi.tuna.tsinghua.edu.cn/simple