TI Deep Learning Product User Guide
Build Instruction

Build instructions for TIDL-RT

By default, TIDL release includes all required pre-built libraries & executables. If there is no code change, you don't need to rebuild it. If code is changed or you want to debug step by step, you can rebuild it by following instructions given in this user guide

  • PC (Windows/Linux, x86_64)
    • TIDL-RT Importer
      • Users can follow the TIDL-RT Importer Guide to know more about import tool and debug it.
      • C++ code is located in ti_dl/utils/tidlModelImport)
    • TIDL-RT Host Emulation - Sample application (test bench)
      • C code for testbench is present in ti_dl/test/src/. TIDL-RT host emulation library is present in ti_dl/lib/PC/
      • This mode should produce the same result as TIDL-RT inference on development board.
      • Please refer the details of sample application to use TIDL-RT
  • TI_DEVICE (J7)
    • TIDL-RT Inference - Sample application (test bench)
      • This application A72 binary can be found inside ti_dl/rt/out/J7/A72/LINUX/< TARGET_BUILD >/TI_DEVICE_a72_test_dl_algo_host_rt.out. Corresponding C7x firmware can be found inside < PSDK_INSTALL_PATH >/vision_apps/out/J7/C71/SYSBIOS/< TARGET_BUILD >/vx_app_rtos_linux_c7x_1.out
      • Steps to run this application are documented here
      • Source code for the testbench is present in ti_dl/test/src/
      • Please refer the details of sample application to use TIDL-RT

Validation Information

Please refer Validation Information section in the TIDeepLearningProduct_ReleaseNotes.html.

Build Dependencies

Before proceeding, please download all the dependent software components

Building PDK

Please note that PDK is a dependency for TIDL and it is available in SDK package. It is expected that user has already built PDK before building TIDL or using pre-built libraries. User should refer to SDK documentation for any issues with PDK build.

Build OpenCV from source

Description here assumes Open CV 4.1.0, but user must make appropriate changes as per the mentioned version in dependent software components

run "unzip opencv-4.1.0.zip" Install cmake if it not available in the system"sudo apt install cmake"

Use below CMake options to in "opencv-4.1.0/cmake" folder. And run "make" from same folder

cmake -DBUILD_opencv_highgui:BOOL="1" -DBUILD_opencv_videoio:BOOL="0" -DWITH_IPP:BOOL="0" -DWITH_WEBP:BOOL="1" -DWITH_OPENEXR:BOOL="1" -DWITH_IPP_A:BOOL="0" -DBUILD_WITH_DYNAMIC_IPP:BOOL="0" -DBUILD_opencv_cudacodec:BOOL="0" -DBUILD_PNG:BOOL="1" -DBUILD_opencv_cudaobjdetect:BOOL="0" -DBUILD_ZLIB:BOOL="1" -DBUILD_TESTS:BOOL="0" -DWITH_CUDA:BOOL="0" -DBUILD_opencv_cudafeatures2d:BOOL="0" -DBUILD_opencv_cudaoptflow:BOOL="0" -DBUILD_opencv_cudawarping:BOOL="0" -DINSTALL_TESTS:BOOL="0" -DBUILD_TIFF:BOOL="1" -DBUILD_JPEG:BOOL="1" -DBUILD_opencv_cudaarithm:BOOL="0" -DBUILD_PERF_TESTS:BOOL="0" -DBUILD_opencv_cudalegacy:BOOL="0" -DBUILD_opencv_cudaimgproc:BOOL="0" -DBUILD_opencv_cudastereo:BOOL="0" -DBUILD_opencv_cudafilters:BOOL="0" -DBUILD_opencv_cudabgsegm:BOOL="0" -DBUILD_SHARED_LIBS:BOOL="0" -DWITH_ITT=OFF ../

Build ProtoBuf from source

Description here assumes protobuf 3.11.3, but user must make appropriate changes as per the mentioned version in dependent software components.

Extract the source "tar -xzvf protobuf-3.11.3.tar.gz"

Run below Configure command in "protobuf-3.11.3" folder and rum "make" from the same folder

./configure CXXFLAGS=-fPIC --enable-shared=no LDFLAGS="-static"

FlatBuffer

Description here assumes protobuf 1.12.0, but user must make appropriate changes as per the mentioned version in dependent software components.

Run the following steps to build flatbuffers:

unzip v1.12.0.zip
cd flatbuffers-1.12.0
cmake -G "Unix Makefiles" -DCMAKE_POSITION_INDEPENDENT_CODE=ON 
make

Tensorflow repository

This dependency is needed for Tensorflow-lite runtime specific builds.

cd ${PSDKRA_PATH}
git clone --depth 1 --single-branch -b tidl-j7 https://github.com/TexasInstruments/tensorflow.git

ONNX repository

This dependency is needed for ONNX runtime specific builds.

cd ${PSDKRA_PATH}
git clone --depth 1 --single-branch -b tidl-j7 https://github.com/TexasInstruments/onnxruntime.git

TVM repository

This dependency is needed for TVM/Neo-AI-DLR specific builds.

cd ${PSDKRA_PATH}
git clone --single-branch -b tidl-j7 https://github.com/TexasInstruments/tvm
cd tvm
git submodule init
git submodule update --init --recursive

Note
Note : If you are building the OpenCV and ProtoBuf in Windows machine. Enable the corresponding flag from CMake wizard..
gmake can be used from CCS for windows building

Windows Build for PDK

  • TIDL depends on certain libraries from PDK and windows libraries for those are not available as part of default SDK package.
  • The same needs to be built by the user and following are the steps for the same :
"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 -vcvars_ver=14.2
  • This section is described for J721E development board and it may differ for other development board
  • PDK build needs XDC tools and this tool is different for windows and linux, so make sure you use the windows version of XDC tools and update the same in pdk_jacinto_xx_xx_xx_xx/packages/ti/build/pdk_tools_path.mk. Change the XDC_INSTALL_PATH in this file.
    • gmake available in "ccs9xx\ccs\utils\bin" can be used for build. Add this path to PATH%
    • Run the below command from "pdk\packages\ti\build" to build PDK Host emulation libraries
      gmake osal_nonos ipc osal_tirtos csl sciclient udma dmautils BOARD=j721e_hostemu CORE=c7x-hostemu -s -j16 BUILD_PROFILE=release
      gmake osal_nonos ipc osal_tirtos csl sciclient udma dmautils BOARD=j721e_hostemu CORE=c7x-hostemu -s -j16 BUILD_PROFILE=debug

Known Issue

In some of the old machines, user many observe "Illegal Instruction" error while importing model or performing inference on PC. This is observed because of new x86_64 instruction used in the pre-built binaries. To overcome this, user would need to re-built the TIDL-RT host emulation executable by executing below command

$ cd ${TIDL_INSTALL_PATH}
$ make tidl TARGET_PLATFORM=PC

Environment Variables

Build system of TIDL-RT software assumes below environment variables being available in the system. Set below environment variables or modify “makerules/config.mk”. Most of these components except described in dependent software components are part of SDK.

Environment Variable Description
IVISION_PATH Directory pointing to ivision package in SDK
DSP_TOOLS Directory pointing to C7x CG tool
MMALIB_PATH Directory pointing to MMA LIB Package (Only needed for TI_DEVICE Build)
PDK_INSTALL_PATH Directory pointing to PDK Package, Default Path refers to pdk in PSDK_INSTALL_PATH, create a symbolic link to pdk_xx_xx_xx_xx with pdk
TIDL_PROTOBUF_PATH Directory pointing to Protobuf package (for Import tool only)
TIDL_FLATBUF_PATH Directory pointing to Flatbuffers package (for Import tool only)
TIDL_OPENCV_PATH Directory pointing to openCV package (for Test bench Only)
UTILS_PATH Directory pointing to utils command like mkdir, rm (can be found inside CCS installation CCS_INSTALLATION_DIR/ccs/utils/cygwin. Required only for Windows builds

Build Commands to run TIDL-RT

Please note that user should use "make" utility for building on Linux whereas "gmake" should be used for Windows. Also executable for Linux have type .out whereas the one for Windows have added .exe in executable name. For simplicity make and .out is used in below section.

Run “make TARGET_PLATFORM=PC” from ${TIDL_INSTALL_PATH} folder to build PC tools

$ cd ${TIDL_INSTALL_PATH}
$ make TARGET_PLATFORM=PC
  • This step will generate all the binaries for PC
    • tidl_model_import.out in "ti_dl/utils/tidlModelImport/out"
    • PC_dsp_test_dl_algo.out in "ti_dl/test"
    • ti_cnnperfsim.out in "ti_dl/utils/perfsim"
  • If you are using a Linux PC, you can run "make" as make gv all TARGET_PLATFORM=PC. This will also generate the graph visulization tool
    • tidl_graphVisualiser.out in "ti_dl/utils/tidlModelGraphviz/out/"

Run “make” from ${TIDL_INSTALL_PATH} folder to build the test bench for target

$ cd ${TIDL_INSTALL_PATH}
$ make
  • This Step will generate binary (./TI_DEVICE_dsp_test_dl_algo.out) in "ti_dl/test"

Use "TARGET_BUILD=debug" to build debug binaries

Additional Build commands for Open Source Runtimes

Pre-requisite : Above TIDL-RT build commands must be executed before running these commands. Note : These builds are supported only on LINUX platform, not supported for Windows.

Import tool build

Following commands can be used to build import tool for open source runtimes.

Tensorflow-lite runtime:

make it TIDL_BUILD_TFLITE_IMPORT_LIB=1

ONNX runtime:

make it TIDL_BUILD_ONNX_IMPORT_LIB=1

TVM/Neo-AI-DLR:

make it TIDL_BUILD_RELAY_IMPORT_LIB=1