Jetson Nano Undefined symbol with Edge Impulse TensorRT deployment with Gstreamer

Question/Issue:
While deploying the tensorRT library of Edge impulse with deepstream on Jetson nano. I keep getting undefined symbol ZN8libeitrt5inferEP5EiTrtPfS2_i which is present in the libei_debug library located at tflite/linux-jetson-nano/libei_debug.a

Context/Use case:
Using edge impulse as a gstreamer plugin for various use cases.

Given below is the Cmake file for reference. I am able to build the shared library but unable to run the application due to undefined symbol ZN8libeitrt5inferEP5EiTrtPfS2_i
project(dsedgeimpulse)

set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/libs)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(DEP_LIB ${CMAKE_SOURCE_DIR}/dsexample_lib/)

find_package(PkgConfig REQUIRED)

find_package(CUDA REQUIRED)

find_package(OpenCV REQUIRED)

pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)

pkg_check_modules(GSTREAMER_BASE REQUIRED gstreamer-base-1.0)

pkg_check_modules(GSTREAMER_VIDEO REQUIRED gstreamer-video-1.0)

set(CMAKE_CXX_STANDARD 14)

set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_C_FLAGS " -fPIC -Wall -g -Wno-strict-aliasing -I. -Isource -Imodel-parameters -Itflite-model -Ithird_party/ -Os -DNDEBUG -DEI_CLASSIFIER_ENABLE_DETECTION_POSTPROCESS_OP=1 -g -Wno-asm-operand-widths -DTF_LITE_DISABLE_X86_NEON=1 -DEI_CLASSIFIER_USE_FULL_TFLITE=1")

message(CMAKE_C_FLAGS = ${CMAKE_C_FLAGS})

#set(CMAKE_CXX_FLAGS “-std=c++14”)

message(CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR})

include_directories(${GSTREAMER_INCLUDE_DIRS})

include_directories(${CUDA_INCLUDE_DIRS})

include_directories(${CMAKE_CURRENT_SOURCE_DIR})

include_directories(/opt/nvidia/deepstream/deepstream/sources/includes/)

include_directories(/usr/local/include/opencv4/)

include_directories(tflite/linux-jetson-nano/)

include_directories(tensorflow-lite/)

include_directories(${DEP_LIB})

link_directories(${GSTREAMER_LIBRARY_DIRS})

link_directories(${CUDA_LIBRARY_DIRS})

link_directories(${OPENCV_LIBRARY_DIRS})

link_directories(${DEP_LIB})

link_directories(/opt/nvidia/deepstream/deepstream/lib)

link_directories(/opt/nvidia/deepstream/deepstream/lib/gst-plugins)

link_directories(/usr/local/cuda-10.2//lib64/)

link_directories(tflite/linux-jetson-nano/)

set(EI_SDK_FOLDER “${CMAKE_CURRENT_SOURCE_DIR}/edge-impulse-sdk”)

include(${EI_SDK_FOLDER}/cmake/utils.cmake)

#target_include_directories(app PRIVATE ${EI_SDK_FOLDER})

#RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES “${EI_SDK_FOLDER}” “*.cpp”)

#RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES “${EI_SDK_FOLDER}” “*.cc”)

#RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES “${EI_SDK_FOLDER}” “*.c”)

#CSOURCES = $(wildcard edge-impulse-sdk/CMSIS/DSP/Source/TransformFunctions/.c) $(wildcard edge-impulse-sdk/CMSIS/DSP/Source/CommonTables/.c)

#$(wildcard edge-impulse-sdk/CMSIS/DSP/Source/BasicMathFunctions/.c) $(wildcard edge-impulse-sdk/CMSIS/DSP/Source/ComplexMathFunctions/.c)

#$(wildcard edge-impulse-sdk/CMSIS/DSP/Source/FastMathFunctions/.c) $(wildcard edge-impulse-sdk/CMSIS/DSP/Source/SupportFunctions/.c)

#$(wildcard edge-impulse-sdk/CMSIS/DSP/Source/MatrixFunctions/.c) $(wildcard edge-impulse-sdk/CMSIS/DSP/Source/StatisticsFunctions/.c)

RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES “${EI_SDK_FOLDER}/CMSIS/DSP/Source/TransformFunctions” “*.c”)

RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES “${EI_SDK_FOLDER}/CMSIS/DSP/Source/CommonTables” “*.c”)

RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES “${EI_SDK_FOLDER}/CMSIS/DSP/Source/BasicMathFunctions” “*.c”)

RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES “${EI_SDK_FOLDER}/CMSIS/DSP/Source/ComplexMathFunctions” “*.c”)

RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES “${EI_SDK_FOLDER}/CMSIS/DSP/Source/FastMathFunctions” “*.c”)

RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES “${EI_SDK_FOLDER}/CMSIS/DSP/Source/SupportFunctions” “*.c”)

RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES “${EI_SDK_FOLDER}/CMSIS/DSP/Source/MatrixFunctions” “*.c”)

RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES “${EI_SDK_FOLDER}/CMSIS/DSP/Source/StatisticsFunctions” “*.c”)

#check

RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES “${EI_SDK_FOLDER}/CMSIS/NN/Source” “*.c”)

#CSOURCES += edge-impulse-sdk/tensorflow/lite/c/common.c

LIST(APPEND EI_SOURCE_FILES “${EI_SDK_FOLDER}/tensorflow/lite/c/common.c”)

#CCSOURCES += $(wildcard edge-impulse-sdk/tensorflow/lite/kernels/.cc) $(wildcard edge-impulse-sdk/tensorflow/lite/kernels/internal/.cc)

#$(wildcard edge-impulse-sdk/tensorflow/lite/micro/kernels/.cc) $(wildcard edge-impulse-sdk/tensorflow/lite/micro/.cc)

#$(wildcard edge-impulse-sdk/tensorflow/lite/micro/memory_planner/.cc) $(wildcard edge-impulse-sdk/tensorflow/lite/core/api/.cc)

#message(EI_SOURCE_FILES="${EI_SOURCE_FILES}")

RECURSIVE_FIND_FILE_APPEND (EI_SOURCE_FILES “${EI_SDK_FOLDER}/tensorflow/lite/kernels” “*.cc”)

RECURSIVE_FIND_FILE_APPEND (EI_SOURCE_FILES “${EI_SDK_FOLDER}/tensorflow/lite/kernels/internal” “*.cc”)

RECURSIVE_FIND_FILE_APPEND (EI_SOURCE_FILES “${EI_SDK_FOLDER}/tensorflow/lite/micro/kernels” “*.cc”)

RECURSIVE_FIND_FILE_APPEND (EI_SOURCE_FILES “${EI_SDK_FOLDER}/tensorflow/lite/micro” “*.cc”)

RECURSIVE_FIND_FILE_APPEND (EI_SOURCE_FILES “${EI_SDK_FOLDER}/tensorflow/lite/micro/memory_planner” “*.cc”)

RECURSIVE_FIND_FILE_APPEND (EI_SOURCE_FILES “${EI_SDK_FOLDER}/tensorflow/lite/core/api” “*.cc”)

RECURSIVE_FIND_FILE_APPEND (EI_SOURCE_FILES “${EI_SDK_FOLDER}/tensorflow/lite/micro/memory_planner” “*.cc”)

RECURSIVE_FIND_FILE_APPEND (EI_SOURCE_FILES “${EI_SDK_FOLDER}/tensorflow/lite/core/api” “*.cc”)

#CXXSOURCES = $(wildcard tflite-model/.cpp) $(wildcard edge-impulse-sdk/dsp/kissfft/.cpp)

#$(wildcard edge-impulse-sdk/dsp/dct/*.cpp) $(wildcard ./edge-impulse-sdk/dsp/memory.cpp)

#$(wildcard edge-impulse-sdk/porting/posix/.c) $(wildcard edge-impulse-sdk/porting/mingw32/.c)

#for gpu version only

LIST(APPEND EI_SOURCE_FILES “tflite-model/onnx-trained.cpp”)

RECURSIVE_FIND_FILE_APPEND (EI_SOURCE_FILES “${EI_SDK_FOLDER}/dsp/kissfft” “*.cpp”)

RECURSIVE_FIND_FILE_APPEND (EI_SOURCE_FILES “${EI_SDK_FOLDER}/dsp/dct” “*.cpp”)

RECURSIVE_FIND_FILE_APPEND (EI_SOURCE_FILES “${EI_SDK_FOLDER}/dsp/dct” “*.cpp”)

LIST(APPEND EI_SOURCE_FILES “${EI_SDK_FOLDER}/dsp/memory.cpp”)

RECURSIVE_FIND_FILE_APPEND (EI_SOURCE_FILES “${EI_SDK_FOLDER}/porting/posix” “*.cpp”)

RECURSIVE_FIND_FILE_APPEND (EI_SOURCE_FILES “${EI_SDK_FOLDER}/porting/mingw32” “*.cpp”)

add_library(nvdsgst_dsexample SHARED gstdsexample.cpp dsexample_lib/dsexample_lib.c ${EI_SOURCE_FILES} tflite/linux-jetson-nano/libei_debug.a )

#tflite/linux-jetson-nano/libcudart.so dsexample_lib/libdsexample.a tflite/linux-jetson-nano/libei_debug.a

target_link_libraries(nvdsgst_dsexample opencv_imgcodecs opencv_video opencv_imgproc opencv_core )

target_link_libraries(nvdsgst_dsexample ${CUDA_LIBRARIES})

target_link_libraries(nvdsgst_dsexample cudart dl nppc nppig npps nppicc nppidei )

target_link_libraries(nvdsgst_dsexample rt )

target_link_libraries(nvdsgst_dsexample ${GSTREAMER_VIDEO_LIBRARIES})

target_link_libraries(nvdsgst_dsexample nvdsgst_helper nvdsgst_meta nvds_meta nvbufsurface nvbufsurftransform )

target_link_libraries(nvdsgst_dsexample nvinfer nvonnxparser)

install(TARGETS nvdsgst_dsexample DESTINATION /opt/nvidia/deepstream/deepstream-6.0/lib/gst-plugins/)

Hi there!
A few questions:

  1. Is this the same issue as you described in Makefile error with gstreamer shared library?
  2. Our standalone inference example for linux is based around Makefile and not CMakeLists… So I’m assuming you are taking deepstream example and trying to integrate Edge Impulse model there?
  3. Would it be possible to share the full project? For us to better understand the issue and reproduce it internally. You can send it over to dmitry@edgeimpulse.com

Hi,

  1. It is slightly different asin previous issue I was integrating with Make file provided from edge impulse which was giving build errors while making a shared library
  2. Yes, I am taking the sample Cmake from edge impulse sdk and trying to integrate with deepstream Cmake. Also added flags from sample Make file for camera application
  3. The size might be huge, Most likely it is a Cmake or libei_debug.so issue when integrating with deepstream. I will try to share relevant files which would help you look into the issue.

Thanks

Hi @kwasif2020 !
After looking and inspecting your build, I came to a conclusion that a rebuild of libeitrt is necessary to use it in the way you want it (a part of gstreamer app).
It’s not very high in list of priority tasks at the moment, so if it urgent for you I recommend you try rebuilding it yourself
here are the instructions

You’ll need to add CMAKE_POSITION_INDEPENDENT_CODE to the CMake file (which adds -fPIC to the linker invoke)

Let me know if you’d like to proceed with building or wait for us to do it (can allocate some time to it in April).

Hi, I had already tried this approach. When i rebuild the TensorRT(8.2) library for edge impulse I get the following error in TensorRT/parsers/onnx/onnx2trt_utils.hpp:376:11
Error IScatterLayer in napsecpace nvinfer1 does not name a type
nvinfer1::IScatterLayer* addScatterLayer(
parsers/onnx/CMakeFiles/nvonnxparser.dir/NvOnnxParser.cpp.o failed
Any clue to fix this?