mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-17 21:10:43 +00:00
linux trt package pipeline (#7537)
This commit is contained in:
parent
8eaa4c33e2
commit
faea7a222d
5 changed files with 189 additions and 1 deletions
|
|
@ -0,0 +1,43 @@
|
|||
variables:
|
||||
PackageName: 'Microsoft.ML.OnnxRuntime.Gpu.Tensorrt'
|
||||
|
||||
jobs:
|
||||
|
||||
- job: Linux_C_API_Packaging_GPU_TensorRT_x64
|
||||
workspace:
|
||||
clean: all
|
||||
timeoutInMinutes: 120
|
||||
pool: 'Onnxruntime-Linux-GPU'
|
||||
variables:
|
||||
CUDA_VERSION: '11.1'
|
||||
steps:
|
||||
- template: templates/set-version-number-variables-step.yml
|
||||
- template: templates/get-docker-image-steps.yml
|
||||
parameters:
|
||||
Dockerfile: tools/ci_build/github/linux/docker/Dockerfile.manylinux2014_cuda11_1_tensorrt7_2
|
||||
Context: tools/ci_build/github/linux/docker
|
||||
DockerBuildArgs: "--build-arg BUILD_UID=$( id -u )"
|
||||
Repository: onnxruntimecuda111trt72build
|
||||
- task: CmdLine@2
|
||||
inputs:
|
||||
script: |
|
||||
mkdir -p $HOME/.onnx
|
||||
docker run --gpus all -e CC=/opt/rh/devtoolset-8/root/usr/bin/cc -e CXX=/opt/rh/devtoolset-8/root/usr/bin/c++ -e CFLAGS="-Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -fstack-clash-protection -fcf-protection -O3 -Wl,--strip-all" -e CXXFLAGS="-Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -fstack-clash-protection -fcf-protection -O3 -Wl,--strip-all" -e NVIDIA_VISIBLE_DEVICES=all --rm --volume /data/onnx:/data/onnx:ro --volume $(Build.SourcesDirectory):/onnxruntime_src --volume $(Build.BinariesDirectory):/build \
|
||||
--volume /data/models:/build/models:ro --volume $HOME/.onnx:/home/onnxruntimedev/.onnx -e NIGHTLY_BUILD onnxruntimecuda111trt72build \
|
||||
/opt/python/cp37-cp37m/bin/python3 /onnxruntime_src/tools/ci_build/build.py --build_dir /build --config Release \
|
||||
--skip_submodule_sync --parallel --build_shared_lib --use_tensorrt --cuda_version=$(CUDA_VERSION) --cuda_home=/usr/local/cuda-$(CUDA_VERSION) --cudnn_home=/usr --tensorrt_home=/usr --cmake_extra_defines CMAKE_CUDA_HOST_COMPILER=/opt/rh/devtoolset-8/root/usr/bin/cc
|
||||
workingDirectory: $(Build.SourcesDirectory)
|
||||
|
||||
- template: templates/c-api-artifacts-package-and-publish-steps-posix.yml
|
||||
parameters:
|
||||
buildConfig: 'Release'
|
||||
artifactName: 'onnxruntime-linux-x64-gpu-tensorrt-$(OnnxRuntimeVersion)'
|
||||
artifactNameNoVersionString: 'onnxruntime-linux-x64-gpu-tensorrt'
|
||||
libraryName: 'libonnxruntime.so.$(OnnxRuntimeVersion)'
|
||||
commitId: $(OnnxRuntimeGitCommitHash)
|
||||
artifactCopyScript: 'tools/ci_build/github/linux/copy_strip_binary_trt.sh'
|
||||
|
||||
- template: templates/component-governance-component-detection-steps.yml
|
||||
parameters :
|
||||
condition : 'succeeded'
|
||||
- template: templates/clean-agent-build-directory-step.yml
|
||||
|
|
@ -20,12 +20,16 @@ parameters:
|
|||
- name: commitId
|
||||
type: string
|
||||
default: ''
|
||||
|
||||
- name: artifactCopyScript
|
||||
type: string
|
||||
default: 'tools/ci_build/github/linux/copy_strip_binary.sh'
|
||||
|
||||
steps:
|
||||
- task: ShellScript@2
|
||||
displayName: 'Copy build artifacts for zipping'
|
||||
inputs:
|
||||
scriptPath: 'tools/ci_build/github/linux/copy_strip_binary.sh'
|
||||
scriptPath: '${{parameters.artifactCopyScript}}'
|
||||
args: '-r $(Build.BinariesDirectory) -a ${{parameters.artifactName}} -l ${{parameters.libraryName}} -c ${{parameters.buildConfig}} -s $(Build.SourcesDirectory) -t ${{parameters.commitId}}'
|
||||
workingDirectory: '$(Build.BinariesDirectory)/${{parameters.buildConfig}}'
|
||||
|
||||
|
|
|
|||
57
tools/ci_build/github/linux/copy_strip_binary_trt.sh
Normal file
57
tools/ci_build/github/linux/copy_strip_binary_trt.sh
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#!/bin/bash
|
||||
set -e -o -x
|
||||
|
||||
while getopts r:a:l:c:s:t: parameter_Option
|
||||
do case "${parameter_Option}"
|
||||
in
|
||||
r) BINARY_DIR=${OPTARG};;
|
||||
a) ARTIFACT_NAME=${OPTARG};;
|
||||
l) LIB_NAME=${OPTARG};;
|
||||
c) BUILD_CONFIG=${OPTARG};;
|
||||
s) SOURCE_DIR=${OPTARG};;
|
||||
t) COMMIT_ID=${OPTARG};;
|
||||
esac
|
||||
done
|
||||
|
||||
EXIT_CODE=1
|
||||
|
||||
uname -a
|
||||
mkdir $BINARY_DIR/$ARTIFACT_NAME
|
||||
mkdir $BINARY_DIR/$ARTIFACT_NAME/lib
|
||||
mkdir $BINARY_DIR/$ARTIFACT_NAME/include
|
||||
echo "Directories created"
|
||||
cp $BINARY_DIR/$BUILD_CONFIG/$LIB_NAME $BINARY_DIR/$ARTIFACT_NAME/lib
|
||||
cp $BINARY_DIR/$BUILD_CONFIG/libonnxruntime_providers_shared.so $BINARY_DIR/$ARTIFACT_NAME/lib
|
||||
cp $BINARY_DIR/$BUILD_CONFIG/libonnxruntime_providers_tensorrt.so $BINARY_DIR/$ARTIFACT_NAME/lib
|
||||
echo "Copy debug symbols in a separate file and strip the original binary."
|
||||
if [[ $LIB_NAME == *.dylib ]]
|
||||
then
|
||||
dsymutil $BINARY_DIR/$ARTIFACT_NAME/lib/$LIB_NAME -o $BINARY_DIR/$ARTIFACT_NAME/lib/$LIB_NAME.dSYM
|
||||
strip -S $BINARY_DIR/$ARTIFACT_NAME/lib/$LIB_NAME
|
||||
ln -s $LIB_NAME $BINARY_DIR/$ARTIFACT_NAME/lib/libonnxruntime.dylib
|
||||
elif [[ $LIB_NAME == *.so.* ]]
|
||||
then
|
||||
ln -s $LIB_NAME $BINARY_DIR/$ARTIFACT_NAME/lib/libonnxruntime.so
|
||||
fi
|
||||
cp $SOURCE_DIR/include/onnxruntime/core/session/onnxruntime_c_api.h $BINARY_DIR/$ARTIFACT_NAME/include
|
||||
cp $SOURCE_DIR/include/onnxruntime/core/session/onnxruntime_cxx_api.h $BINARY_DIR/$ARTIFACT_NAME/include
|
||||
cp $SOURCE_DIR/include/onnxruntime/core/session/onnxruntime_cxx_inline.h $BINARY_DIR/$ARTIFACT_NAME/include
|
||||
cp $SOURCE_DIR/include/onnxruntime/core/providers/cpu/cpu_provider_factory.h $BINARY_DIR/$ARTIFACT_NAME/include
|
||||
cp $SOURCE_DIR/include/onnxruntime/core/providers/cuda/cuda_provider_factory.h $BINARY_DIR/$ARTIFACT_NAME/include
|
||||
cp $SOURCE_DIR/include/onnxruntime/core/providers/tensorrt/tensorrt_provider_factory.h $BINARY_DIR/$ARTIFACT_NAME/include
|
||||
cp $SOURCE_DIR/include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h $BINARY_DIR/$ARTIFACT_NAME/include
|
||||
|
||||
# copy the README, licence and TPN
|
||||
cp $SOURCE_DIR/README.md $BINARY_DIR/$ARTIFACT_NAME/README.md
|
||||
cp $SOURCE_DIR/docs/Privacy.md $BINARY_DIR/$ARTIFACT_NAME/Privacy.md
|
||||
cp $SOURCE_DIR/LICENSE $BINARY_DIR/$ARTIFACT_NAME/LICENSE
|
||||
cp $SOURCE_DIR/ThirdPartyNotices.txt $BINARY_DIR/$ARTIFACT_NAME/ThirdPartyNotices.txt
|
||||
cp $SOURCE_DIR/VERSION_NUMBER $BINARY_DIR/$ARTIFACT_NAME/VERSION_NUMBER
|
||||
|
||||
|
||||
echo $COMMIT_ID > $BINARY_DIR/$ARTIFACT_NAME/GIT_COMMIT_ID
|
||||
|
||||
EXIT_CODE=$?
|
||||
|
||||
set -e
|
||||
exit $EXIT_CODE
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
FROM nvcr.io/nvidia/cuda:11.1-cudnn8-devel-centos7
|
||||
|
||||
#We need CUDA, TensorRT and manylinux. But the CUDA Toolkit End User License Agreement says NVIDIA CUDA Driver Libraries(libcuda.so, libnvidia-ptxjitcompiler.so) are only distributable in applications that meet this criteria:
|
||||
#1. The application was developed starting from a NVIDIA CUDA container obtained from Docker Hub or the NVIDIA GPU Cloud, and
|
||||
#2. The resulting application is packaged as a Docker container and distributed to users on Docker Hub or the NVIDIA GPU Cloud only.
|
||||
#So we use CUDA as the base image then add manylinux and TensorRT on top of it.
|
||||
|
||||
#Build manylinux2014 docker image begin
|
||||
ENV AUDITWHEEL_ARCH x86_64
|
||||
ENV AUDITWHEEL_PLAT manylinux2014_$AUDITWHEEL_ARCH
|
||||
ENV LC_ALL en_US.UTF-8
|
||||
ENV LANG en_US.UTF-8
|
||||
ENV LANGUAGE en_US.UTF-8
|
||||
ENV DEVTOOLSET_ROOTPATH /opt/rh/devtoolset-9/root
|
||||
ENV PATH $DEVTOOLSET_ROOTPATH/usr/bin:$PATH
|
||||
ENV LD_LIBRARY_PATH $DEVTOOLSET_ROOTPATH/usr/lib64:$DEVTOOLSET_ROOTPATH/usr/lib:$DEVTOOLSET_ROOTPATH/usr/lib64/dyninst:$DEVTOOLSET_ROOTPATH/usr/lib/dyninst:/usr/local/lib64:/usr/local/lib
|
||||
ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig
|
||||
|
||||
COPY manylinux2014_build_scripts /manylinux2014_build_scripts
|
||||
RUN bash /manylinux2014_build_scripts/build.sh 8 && rm -r manylinux2014_build_scripts && yum downgrade -y glibc-2.17-317.el7 glibc-common-2.17-317.el7 glibc-devel-2.17-317.el7 glibc-headers-2.17-317.el7
|
||||
|
||||
ENV SSL_CERT_FILE=/opt/_internal/certs.pem
|
||||
|
||||
#Build manylinux2014 docker image end
|
||||
|
||||
#Install TensorRT 7.2.2.2
|
||||
RUN yum install -y wget
|
||||
RUN cd /tmp &&\
|
||||
wget --no-check-certificate https://developer.download.nvidia.com/compute/machine-learning/repos/rhel7/x86_64/nvidia-machine-learning-repo-rhel7-1.0.0-1.x86_64.rpm &&\
|
||||
rpm -Uvh nvidia-machine-learning-repo-*.rpm
|
||||
RUN yum install -y libnvinfer7-7.2.2-1.cuda11.1 libnvparsers7-7.2.2-1.cuda11.1 libnvinfer-plugin7-7.2.2-1.cuda11.1 libnvonnxparsers7-7.2.2-1.cuda11.1 libnvinfer-devel-7.2.2-1.cuda11.1 libnvparsers-devel-7.2.2-1.cuda11.1 libnvinfer-plugin-devel-7.2.2-1.cuda11.1
|
||||
|
||||
#Add our own dependencies
|
||||
ADD scripts /tmp/scripts
|
||||
RUN cd /tmp/scripts && /tmp/scripts/manylinux/install_centos.sh && /tmp/scripts/manylinux/install_deps.sh && rm -rf /tmp/scripts
|
||||
|
||||
ARG BUILD_UID=1001
|
||||
ARG BUILD_USER=onnxruntimedev
|
||||
RUN adduser --uid $BUILD_UID $BUILD_USER
|
||||
WORKDIR /home/$BUILD_USER
|
||||
USER $BUILD_USER
|
||||
ENV PATH /usr/local/gradle/bin:/usr/local/dotnet:$PATH
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
FROM nvcr.io/nvidia/cuda:11.0-cudnn8-devel-centos7
|
||||
|
||||
#We need CUDA, TensorRT and manylinux. But the CUDA Toolkit End User License Agreement says NVIDIA CUDA Driver Libraries(libcuda.so, libnvidia-ptxjitcompiler.so) are only distributable in applications that meet this criteria:
|
||||
#1. The application was developed starting from a NVIDIA CUDA container obtained from Docker Hub or the NVIDIA GPU Cloud, and
|
||||
#2. The resulting application is packaged as a Docker container and distributed to users on Docker Hub or the NVIDIA GPU Cloud only.
|
||||
#So we use CUDA as the base image then add manylinux and TensorRT on top of it.
|
||||
|
||||
#Build manylinux2014 docker image begin
|
||||
ENV AUDITWHEEL_ARCH x86_64
|
||||
ENV AUDITWHEEL_PLAT manylinux2014_$AUDITWHEEL_ARCH
|
||||
ENV LC_ALL en_US.UTF-8
|
||||
ENV LANG en_US.UTF-8
|
||||
ENV LANGUAGE en_US.UTF-8
|
||||
ENV DEVTOOLSET_ROOTPATH /opt/rh/devtoolset-9/root
|
||||
ENV PATH $DEVTOOLSET_ROOTPATH/usr/bin:$PATH
|
||||
ENV LD_LIBRARY_PATH $DEVTOOLSET_ROOTPATH/usr/lib64:$DEVTOOLSET_ROOTPATH/usr/lib:$DEVTOOLSET_ROOTPATH/usr/lib64/dyninst:$DEVTOOLSET_ROOTPATH/usr/lib/dyninst:/usr/local/lib64:/usr/local/lib
|
||||
ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig
|
||||
|
||||
COPY manylinux2014_build_scripts /manylinux2014_build_scripts
|
||||
RUN bash /manylinux2014_build_scripts/build.sh 8 && rm -r manylinux2014_build_scripts && yum downgrade -y glibc-2.17-317.el7 glibc-common-2.17-317.el7 glibc-devel-2.17-317.el7 glibc-headers-2.17-317.el7
|
||||
|
||||
ENV SSL_CERT_FILE=/opt/_internal/certs.pem
|
||||
|
||||
#Build manylinux2014 docker image end
|
||||
|
||||
#Install TensorRT 7.2.2.2
|
||||
RUN yum install -y wget
|
||||
RUN cd /tmp &&\
|
||||
wget --no-check-certificate https://developer.download.nvidia.com/compute/machine-learning/repos/rhel7/x86_64/nvidia-machine-learning-repo-rhel7-1.0.0-1.x86_64.rpm &&\
|
||||
rpm -Uvh nvidia-machine-learning-repo-*.rpm
|
||||
RUN yum install -y libnvinfer7-7.2.2-1.cuda11.0 libnvparsers7-7.2.2-1.cuda11.0 libnvinfer-plugin7-7.2.2-1.cuda11.0 libnvonnxparsers7-7.2.2-1.cuda11.0 libnvinfer-devel-7.2.2-1.cuda11.0 libnvparsers-devel-7.2.2-1.cuda11.0 libnvinfer-plugin-devel-7.2.2-1.cuda11.0
|
||||
|
||||
#Add our own dependencies
|
||||
ADD scripts /tmp/scripts
|
||||
RUN cd /tmp/scripts && /tmp/scripts/manylinux/install_centos.sh && /tmp/scripts/manylinux/install_deps.sh && rm -rf /tmp/scripts
|
||||
|
||||
ARG BUILD_UID=1001
|
||||
ARG BUILD_USER=onnxruntimedev
|
||||
RUN adduser --uid $BUILD_UID $BUILD_USER
|
||||
WORKDIR /home/$BUILD_USER
|
||||
USER $BUILD_USER
|
||||
ENV PATH /usr/local/gradle/bin:/usr/local/dotnet:$PATH
|
||||
Loading…
Reference in a new issue