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

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into port_website_fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
josephevans committed May 16, 2022
2 parents 63092a8 + eb8982d commit 6eb5c25
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 29 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/onnx-tensorrt
Submodule onnx-tensorrt updated 58 files
+44 −0 .github/ISSUE_TEMPLATE/bug_report.md
+56 −67 CMakeLists.txt
+338 −0 ConditionalHelpers.cpp
+52 −0 ConditionalHelpers.hpp
+146 −76 ImporterContext.hpp
+202 −22 LICENSE
+22 −0 LoopHelpers.cpp
+16 −0 LoopHelpers.hpp
+277 −177 ModelImporter.cpp
+6 −36 ModelImporter.hpp
+1 −19 NvOnnxParser.cpp
+35 −56 NvOnnxParser.h
+66 −25 OnnxAttrs.cpp
+12 −20 OnnxAttrs.hpp
+46 −37 README.md
+176 −0 RNNHelpers.cpp
+31 −0 RNNHelpers.hpp
+287 −151 ShapeTensor.cpp
+132 −54 ShapeTensor.hpp
+71 −33 ShapedWeights.cpp
+34 −23 ShapedWeights.hpp
+11 −21 Status.hpp
+34 −19 TensorOrWeights.hpp
+2,403 −950 builtin_op_importers.cpp
+1 −19 builtin_op_importers.hpp
+2 −20 common.hpp
+0 −3 contributing.md
+0 −70 docker/onnx-tensorrt-deb.Dockerfile
+0 −80 docker/onnx-tensorrt-tar.Dockerfile
+124 −0 docs/Changelog.md
+61 −0 docs/contributing.md
+51 −0 docs/faq.md
+181 −0 docs/operators.md
+12 −30 getSupportedAPITest.cpp
+7 −29 main.cpp
+0 −64 nv_onnx_parser_bindings.i
+7 −20 onnx2trt.hpp
+16 −26 onnx2trt_common.hpp
+1 −19 onnx2trt_runtime.hpp
+1,076 −438 onnx2trt_utils.cpp
+130 −52 onnx2trt_utils.hpp
+121 −0 onnxErrorRecorder.cpp
+106 −0 onnxErrorRecorder.hpp
+3 −19 onnx_backend_test.py
+3 −19 onnx_tensorrt/__init__.py
+80 −44 onnx_tensorrt/backend.py
+0 −30 onnx_tensorrt/config.py
+0 −23 onnx_tensorrt/parser/__init__.py
+0 −23 onnx_tensorrt/runtime/__init__.py
+20 −31 onnx_tensorrt/tensorrt_engine.py
+972 −890 onnx_trt_backend.cpp
+43 −35 onnx_utils.hpp
+0 −169 operators.md
+34 −102 setup.py
+1 −1 third_party/onnx
+1 −19 toposort.hpp
+1 −25 trt_utils.hpp
+1 −19 utils.hpp
28 changes: 11 additions & 17 deletions ci/docker/Dockerfile.build.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -159,25 +159,19 @@ SHELL ["/bin/bash", "-c"]
# We need to redeclare ARG due to
# https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
ARG BASE_IMAGE
RUN export SHORT_CUDA_VERSION=${CUDA_VERSION%.*} && \
export OS_RELEASE="$(cat /etc/os-release)" && \
apt-get update && \
apt-get install -y --allow-change-held-packages libcudnn8 libcudnn8-dev && \
if [[ ${OS_RELEASE} == *"Bionic"* ]]; then \
if [ ${SHORT_CUDA_VERSION} = 11.0 ]; then \
TRT_VERSION="7.2.0-1+cuda11.0"; \
TRT_MAJOR_VERSION=7; \
elif [ ${SHORT_CUDA_VERSION} = 11.1 ]; then \
TRT_VERSION="7.2.1-1+cuda11.1"; \
TRT_MAJOR_VERSION=7; \
else \
echo "ERROR: Cuda ${SHORT_CUDA_VERSION} not yet supported in Dockerfile.build.ubuntu"; \
exit 1; \
fi; \
RUN apt-get update && \
apt-get install -y --allow-change-held-packages libcudnn8 libcudnn8-dev && \
rm -rf /var/lib/apt/lists/*

ARG TRT_VERSION
RUN if [ ! -z "${TRT_VERSION}" ]; then \
apt-get update && \
TRT_MAJOR_VERSION=$(echo $TRT_VERSION | cut -d. -f 1) && \
apt-get install -y libnvinfer${TRT_MAJOR_VERSION}=${TRT_VERSION} \
libnvinfer-dev=${TRT_VERSION} \
libnvinfer-plugin${TRT_MAJOR_VERSION}=${TRT_VERSION} \
libnvinfer-plugin-dev=${TRT_VERSION}; \
fi && \
rm -rf /var/lib/apt/lists/*
rm -rf /var/lib/apt/lists/*; \
fi


13 changes: 7 additions & 6 deletions ci/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ services:
dockerfile: Dockerfile.build.centos7
target: base
args:
BASE_IMAGE: nvidia/cuda:11.0-cudnn8-devel-centos7
BASE_IMAGE: nvidia/cuda:11.0.3-cudnn8-devel-centos7
cache_from:
- ${DOCKER_CACHE_REGISTRY}/build.centos7_gpu_cu110:latest
centos7_gpu_cu112:
Expand Down Expand Up @@ -98,24 +98,25 @@ services:
BASE_IMAGE: ubuntu:20.04
cache_from:
- ${DOCKER_CACHE_REGISTRY}/build.ubuntu_cpu:latest
ubuntu_tensorrt_cu111:
image: ${DOCKER_CACHE_REGISTRY}/build.ubuntu_tensorrt_cu111:latest
ubuntu_tensorrt_cu114:
image: ${DOCKER_CACHE_REGISTRY}/build.ubuntu_tensorrt_cu114:latest
build:
context: .
dockerfile: Dockerfile.build.ubuntu
target: gpu
args:
BASE_IMAGE: nvidia/cuda:11.1-cudnn8-devel-ubuntu18.04
BASE_IMAGE: nvidia/cuda:11.4.0-cudnn8-devel-ubuntu20.04
TRT_VERSION: 8.2.4-1+cuda11.4
cache_from:
- ${DOCKER_CACHE_REGISTRY}/build.ubuntu_tensorrt_cu111:latest
- ${DOCKER_CACHE_REGISTRY}/build.ubuntu_tensorrt_cu114:latest
ubuntu_gpu_cu111:
image: ${DOCKER_CACHE_REGISTRY}/build.ubuntu_gpu_cu111:latest
build:
context: .
dockerfile: Dockerfile.build.ubuntu
target: gpu
args:
BASE_IMAGE: nvidia/cuda:11.1-cudnn8-devel-ubuntu20.04
BASE_IMAGE: nvidia/cuda:11.1.1-cudnn8-devel-ubuntu20.04
cache_from:
- ${DOCKER_CACHE_REGISTRY}/build.ubuntu_gpu_cu111:latest
###################################################################################################
Expand Down
18 changes: 15 additions & 3 deletions ci/docker/runtime_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ CI_CMAKE_CUDA10_ARCH="5.2 7.5"
# compute capabilities for CI instances supported by CUDA >= 11.1 (i.e. p3, g4, g5)
CI_CMAKE_CUDA_ARCH="5.2 7.5 8.6"

# On newer nvidia cuda containers, these environment variables
# are prefixed with NV_, so provide compatibility
if [ ! -z "$NV_CUDNN_VERSION" ]; then
if [ -z "$CUDNN_VERSION" ]; then
export CUDNN_VERSION=$NV_CUDNN_VERSION
fi
fi

clean_repo() {
set -ex
git clean -xfd
Expand Down Expand Up @@ -548,6 +556,9 @@ build_ubuntu_gpu_tensorrt() {
export CC=gcc-7
export CXX=g++-7
export ONNX_NAMESPACE=onnx
export PYBIN=$(which python3)
PYVERFULL=$($PYBIN -V | awk '{print $2}')
export PYVER=${PYVERFULL%.*}

# Build ONNX
pushd .
Expand All @@ -556,7 +567,7 @@ build_ubuntu_gpu_tensorrt() {
rm -rf build
mkdir -p build
cd build
cmake -DCMAKE_CXX_FLAGS=-I/usr/include/python${PYVER} -DBUILD_SHARED_LIBS=ON ..
cmake -DPYTHON_EXECUTABLE=$PYBIN -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
Expand All @@ -566,12 +577,12 @@ build_ubuntu_gpu_tensorrt() {

# Build ONNX-TensorRT
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
export CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}:/usr/local/cuda-10.2/targets/x86_64-linux/include/
export CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}:/usr/local/cuda/targets/x86_64-linux/include/
pushd .
cd 3rdparty/onnx-tensorrt/
mkdir -p build
cd build
cmake -DONNX_NAMESPACE=$ONNX_NAMESPACE ..
cmake -DPYTHON_EXECUTABLE=$PYBIN -DONNX_NAMESPACE=$ONNX_NAMESPACE ..
make -j$(nproc)
export LIBRARY_PATH=`pwd`:$LIBRARY_PATH
popd
Expand All @@ -585,6 +596,7 @@ build_ubuntu_gpu_tensorrt() {
-DUSE_CUDNN=1 \
-DUSE_OPENCV=1 \
-DUSE_TENSORRT=1 \
-DUSE_INT64_TENSOR_SIZE=1 \
-DUSE_OPENMP=0 \
-DUSE_BLAS=Open \
-DUSE_ONEDNN=0 \
Expand Down
2 changes: 1 addition & 1 deletion ci/jenkins/Jenkins_steps.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def compile_unix_tensorrt_gpu(lib_name) {
ws('workspace/build-tensorrt') {
timeout(time: max_time, unit: 'MINUTES') {
utils.init_git()
utils.docker_run('ubuntu_tensorrt_cu111', 'build_ubuntu_gpu_tensorrt', false)
utils.docker_run('ubuntu_tensorrt_cu114', 'build_ubuntu_gpu_tensorrt', false)
utils.pack_lib(lib_name, mx_tensorrt_lib)
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/operator/subgraph/tensorrt/onnx_to_tensorrt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,32 @@ onnxToTrtCtx(const std::string& onnx_model,
}
throw dmlc::Error("Cannot parse ONNX into TensorRT Engine");
}
#if NV_TENSORRT_MAJOR >= 8
auto trt_config = InferObject(trt_builder->createBuilderConfig());
#endif
if (dmlc::GetEnv("MXNET_TENSORRT_USE_FP16", true)) {
if (trt_builder->platformHasFastFp16()) {
#if NV_TENSORRT_MAJOR >= 8
trt_config->setFlag(nvinfer1::BuilderFlag::kFP16);
#else
trt_builder->setFp16Mode(true);
#endif
} else {
LOG(WARNING) << "TensorRT can't use fp16 on this platform";
}
}
trt_builder->setMaxBatchSize(max_batch_size);
#if NV_TENSORRT_MAJOR >= 8
trt_config->setMaxWorkspaceSize(max_workspace_size);
if (debug_builder) {
trt_config->setFlag(nvinfer1::BuilderFlag::kDEBUG);
}
auto trt_engine = InferObject(trt_builder->buildEngineWithConfig(*trt_network, *trt_config));
#else
trt_builder->setMaxWorkspaceSize(max_workspace_size);
trt_builder->setDebugSync(debug_builder);
auto trt_engine = InferObject(trt_builder->buildCudaEngine(*trt_network));
#endif
return std::make_tuple(std::move(trt_engine), std::move(trt_parser), std::move(trt_logger));
}

Expand Down
2 changes: 1 addition & 1 deletion src/operator/subgraph/tensorrt/onnx_to_tensorrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class TRT_Logger : public nvinfer1::ILogger {
public:
TRT_Logger(Severity verbosity = Severity::kWARNING, std::ostream& ostream = std::cout) // NOLINT
: _verbosity(verbosity), _ostream(&ostream) {}
void log(Severity severity, const char* msg) override {
void log(Severity severity, const char* msg) noexcept override {
if (severity <= _verbosity) {
time_t rawtime = std::time(0);
char buf[256];
Expand Down

0 comments on commit 6eb5c25

Please sign in to comment.