Installing DLR

Installing Pre-built DLR Wheels for Your Device

DLR has been built and tested aginast devices in table 1. If you find your device(s) listed below, you can install DLR with the corresponding S3 link via

pip install  link-to-matching-wheel-on-S3

Table 1: List of Supported Devices


Device Name

Wheel URL on S3




A1 Instance


P3 Instance








Hikey 960











If your device is not listed in the table, use table2. You will identify your device by the processor architecture, operating system, and versions of GLIBC and LIBSTDC++. Of note, DLR installation may depend on other configuration differences or even location of dependency libraries; if the provided wheel URL does not work, please consider compiling DLR from source (see Building DLR from source section).

Table2: List of Supported Architectures (Incomplete)

Processor architecture


GLIBC version

LIBSTDC++ version

Wheel URL on S3


Ubuntu 16.04




Debian 9.0



Building DLR from source

Building DLR consists of two steps:

  1. Build the shared library from C++ code ( for Linux, libdlr.dylib for Mac OSX, and dlr.dll for Windows).

  2. Then install the Python package dlr.


Use of Git submodules

DLR uses Git submodules to manage dependencies. So when you clone the repo, remember to specify --recursive option:

git clone --recursive
cd neo-ai-dlr

Building on Linux

Ensure that all necessary software packages are installed: GCC (or Clang), CMake, and Python. For example, in Ubuntu, you can run

sudo apt-get update
sudo apt-get install -y python3 python3-pip gcc build-essential cmake

To build, create a subdirectory build:

mkdir build
cd build

Building for CPU

Invoke CMake to generate a Makefile and then run GNU Make to compile:

cmake ..
make -j4         # Use 4 cores to compile sources in parallel

Building for GPU

By default, DLR will be built with CPU support only. To enable support for NVIDIA GPUs, enable CUDA, CUDNN, and TensorRT by calling CMake with these extra options.

If you have a system install of TensorRT via Deb or RPM package, or if you are on a Jetson device, use the following configuration:

make -j4

If you do not have a system install of TensorRT and have downloaded it via tar file or zip, provide the path to the extracted TensorRT directory with:

make -j4

You will need to install NVIDIA CUDA and TensorRT toolkits and drivers beforehand.

Building for OpenCL Devices

Similarly, to enable support for OpenCL devices, run CMake with:

cmake .. -DUSE_OPENCL=ON
make -j4

Install Python package

Once the compilation is completed, install the Python package by running

cd ../python
python3 install --user --force

Building on Mac OS X

Install GCC and CMake from Homebrew:

brew update
brew install cmake gcc@8

To ensure that Homebrew GCC is used (instead of default Apple compiler), specify environment variables CC and CXX when invoking CMake:

mkdir build
cd build
CC=gcc-8 CXX=g++-8 cmake ..
make -j4

NVIDIA GPUs are not supported for Mac OS X target.

Once the compilation is completed, install the Python package by running

cd ../python
python3 install --user --prefix=''

Building on Windows

DLR requires Visual Studio 2017 as well as CMake.

In the DLR directory, first run CMake to generate a Visual Studio project:

mkdir build
cd build
cmake .. -G"Visual Studio 15 2017 Win64"

If CMake run was successful, you should be able to find the solution file dlr.sln. Open it with Visual Studio. To build, choose Build Solution on the Build menu.

NVIDIA GPUs are not yet supported for Windows target.

Once the compilation is completed, install the Python package by running

cd ../python
python3 install --user

Building for Android on ARM

Android build requires Android NDK. We utilize the android.toolchain.cmake file in NDK package to configure the crosscompiler

Also required is NDK standlone toolchain. Follow the instructions to generate necessary build-essential tools.

Once done with above steps, invoke cmake with following commands to build Android shared lib:

  -DNDK_ROOT=/path/to/your/ndk/folder \
  -DCMAKE_TOOLCHAIN_FILE=/path/to/your/ndk/folder/build/cmake/android.toolchain.cmake \

make -j4

ANDROID_PLATFORM should correspond to minSdkVersion of your project. If ANDROID_PLATFORM is not set it will default to android-21.

For arm64 targets, add


to cmake flags.

Building DLR with TFLite

DLR build can include libtensorflow-lite.a library into shared library.

Currently DLR supports TFLite 1.15.2 (branch r1.15). Build libtensorflow-lite.a as explained here

To build libtensorflow-lite.a for Android you can look at this docs

Attention! You need to apply the following patches to tensorflow r1.15 branch:

To build DLR with TFLite use cmake flag WITH_TENSORFLOW_LITE_LIB, e.g.

cmake .. \

To test DLR with TFLite use dlr_tflite_test


Building for Android Archive (AAR) file

Install Android Studio.

cd aar
# create file
# put line containing path to Android/sdk
# sdk.dir=/Users/root/Library/Android/sdk

# Run gradle build
./gradlew assembleRelease

# dlr-release.aar file will be under dlr/build/outputs/aar/ folder
ls -lah dlr/build/outputs/aar/dlr-release.aar

Validation After Build (Linux Only)

cd tests/python/integration/