Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
[v1.x] Simplify TRT build by adding dependency builder script
Browse files Browse the repository at this point in the history
Signed-off-by: Serge Panev <[email protected]>
  • Loading branch information
Kh4L committed Jan 12, 2021
1 parent aa00f4b commit c64c14f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 30 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ endif()

if(USE_TENSORRT)
message(STATUS "Using TensorRT")
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/)

Expand Down
31 changes: 1 addition & 30 deletions ci/docker/runtime_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
31 changes: 31 additions & 0 deletions tools/dependencies/build_onnx_trt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export ONNX_NAMESPACE=onnx
PYTHON_ROOT_PATH=`python -c "import sys; print('\n'.join(sys.path))"`

ONNX_TRT_INSTALLED=`ldconfig -p | grep -c libnvonnxparser`
if [ $ONNX_TRT_INSTALLED -eq "0" ]; then
# Build ONNX
pushd 3rdparty/onnx-tensorrt/third_party/onnx
mkdir -p build
pushd build
cmake -DCMAKE_CXX_FLAGS=-I$(PYTHON_ROOT_PATH) -DBUILD_SHARED_LIBS=ON ..
make -j$(nproc) install
ldconfig
popd
mkdir /usr/include/x86_64-linux-gnu/onnx
cp build/onnx/onnx*pb.* /usr/include/x86_64-linux-gnu/onnx
cp build/libonnx.so /usr/local/lib
ldconfig
popd

# Build onnx tensorrt
pushd /opt/mxnet/3rdparty/onnx-tensorrt
mkdir -p build
pushd build
cmake -DONNX_NAMESPACE=$ONNX_NAMESPACE ..
make -j$(nproc) install
ldconfig
popd
popd
else
echo "onnx_tensorrt already installed."
fi

0 comments on commit c64c14f

Please sign in to comment.