TI Deep Learning Library User Guide
Build Instruction

What can be built with TIDL release

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 Importer
      • Users can follow the TIDL Importer Guide to know more about import tool and debug it.
      • C++ code is located in ti_dl/utils/tidlModelImport)
    • TIDL Host Emulation - Sample application
      • C code for testbench is present in ti_dl/test/src/. TIDL host emulation library is present in ti_dl/lib/PC/
      • This tool should produce the same result as TIDL inference on target side.
      • Please refer the TIDL Sample Application doc
  • TI_DEVICE (J7)
    • TIDL Inference - Sample application (test bench)
      • This application can be loaded using CCS on J7 SoC. This is mainly used for TIDL standalone testing without SDK.
      • C code for testbench is present in ti_dl/test/src/. TIDL target library is present in ti_dl/lib/dsp/
      • This application should produce the same result as TIDL integrated in SDK.
      • Please refer the TIDL Sample Application doc

Validation Information

Please refer Validation Information section in the TIDeepLearningLibrary_ReleaseNotes.html.

Environment Variables

Build system of TIDL software assumes below environment variables being available in the system. Set below environment variables or modify “makerules/config.mk”

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

Please note that use 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

Build Dependencies

Building PDK

Please note that PDK is a dependency for TIDL. 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

Download open CV Source from : https://github.com/opencv/opencv/archive/3.1.0.zip run "unzip opencv-3.1.0.zip" Install cmake if it not available in the system"sudo apt install cmake"

Use below CMake options to in "opencv-3.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" ../

Build ProtoBuf from source

Download ProtoBuf source: https://github.com/protocolbuffers/protobuf/releases/download/v3.5.1/protobuf-cpp-3.5.1.tar.gz

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

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

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

FlatBuffer

Download flatbuffers from here : https://github.com/google/flatbuffers/archive/v1.12.0.zip 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

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

  • Download and install build tools from : https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019
  • Run below command from to set MSVC build environment
    "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 -vcvars_ver=14.2
  • gmake available in "ccs9xx\ccs\utils\bin" can be used for build. Add this path to PATH%
  • The PDK Host emulation libraries for windows build are not available in the PSDKRA package. 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 running 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 PC executable by running below command

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