diff --git a/CMakeLists.txt b/CMakeLists.txt index c4b37bb8a2ad..15cd8317fe2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -237,6 +237,12 @@ endif() if(USE_TENSORRT) message(STATUS "Using TensorRT") + add_definitions(-DMXNET_USE_TENSORRT=1) + add_definitions(-DONNX_NAMESPACE=onnx) + add_definitions(-DONNX_ML=1) + add_definitions(-DBUILD_SHARED_LIBS=ON) + add_subdirectory(3rdparty/onnx_tensorrt/ EXCLUDE_FROM_ALL) + execute_process(COMMAND bash tools/dependencies/build_onnx_trt.sh) set(ONNX_PATH 3rdparty/onnx-tensorrt/third_party/onnx/build/) set(ONNX_TRT_PATH 3rdparty/onnx-tensorrt/build/) @@ -244,9 +250,6 @@ if(USE_TENSORRT) include_directories(3rdparty/onnx-tensorrt/) include_directories(3rdparty/) include_directories(3rdparty/onnx-tensorrt/third_party/onnx/) - add_definitions(-DMXNET_USE_TENSORRT=1) - add_definitions(-DONNX_NAMESPACE=onnx) - add_definitions(-DONNX_ML=1) find_package(Protobuf REQUIRED) diff --git a/ci/docker/runtime_functions.sh b/ci/docker/runtime_functions.sh index 60f1c289c0a7..6482f3d0b968 100755 --- a/ci/docker/runtime_functions.sh +++ b/ci/docker/runtime_functions.sh @@ -709,40 +709,11 @@ build_ubuntu_gpu_tensorrt() { build_ccache_wrappers - export ONNX_NAMESPACE=onnx - - # Build ONNX - pushd . - echo "Installing ONNX." - cd 3rdparty/onnx-tensorrt/third_party/onnx - rm -rf build - mkdir -p build - cd build - cmake -DCMAKE_CXX_FLAGS=-I/usr/include/python${PYVER} -DBUILD_SHARED_LIBS=ON .. - make -j$(nproc) - export LIBRARY_PATH=`pwd`:`pwd`/onnx/:$LIBRARY_PATH - export CPLUS_INCLUDE_PATH=`pwd`:$CPLUS_INCLUDE_PATH - export CXXFLAGS=-I`pwd` - popd - - # Build ONNX-TensorRT - pushd . - cd 3rdparty/onnx-tensorrt/ - mkdir -p build - cd build - cmake -DONNX_NAMESPACE=$ONNX_NAMESPACE .. - make -j$(nproc) - export LIBRARY_PATH=`pwd`:$LIBRARY_PATH - popd - - mkdir -p /work/mxnet/lib/ - cp 3rdparty/onnx-tensorrt/third_party/onnx/build/*.so /work/mxnet/lib/ - cp -L 3rdparty/onnx-tensorrt/build/libnvonnxparser.so* /work/mxnet/lib/ - cd /work/build cmake -DUSE_CUDA=1 \ -DUSE_CUDNN=1 \ -DUSE_OPENCV=1 \ + -DONNX_NAMESPACE=onnx \ -DUSE_TENSORRT=1 \ -DUSE_OPENMP=0 \ -DUSE_MKLDNN=0 \