2019-07-09 09:03:55 +00:00
|
|
|
# --------------------------------------------------------------
|
|
|
|
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
|
# Licensed under the MIT License.
|
|
|
|
|
# --------------------------------------------------------------
|
|
|
|
|
# Dockerfile to run ONNXRuntime with TensorRT integration
|
|
|
|
|
|
|
|
|
|
# nVidia TensorRT Base Image
|
2023-03-01 15:02:42 +00:00
|
|
|
ARG TRT_CONTAINER_VERSION=22.12
|
2022-01-12 00:12:32 +00:00
|
|
|
FROM nvcr.io/nvidia/tensorrt:${TRT_CONTAINER_VERSION}-py3
|
2019-07-09 09:03:55 +00:00
|
|
|
|
|
|
|
|
ARG ONNXRUNTIME_REPO=https://github.com/Microsoft/onnxruntime
|
2022-08-16 21:13:05 +00:00
|
|
|
ARG ONNXRUNTIME_BRANCH=main
|
2025-01-14 22:27:34 +00:00
|
|
|
# Adjust as needed
|
|
|
|
|
# Check your CUDA arch: https://developer.nvidia.com/cuda-gpus
|
|
|
|
|
ARG CMAKE_CUDA_ARCHITECTURES=75;80;90
|
2019-07-09 09:03:55 +00:00
|
|
|
|
|
|
|
|
RUN apt-get update &&\
|
2020-08-15 01:12:27 +00:00
|
|
|
apt-get install -y sudo git bash unattended-upgrades
|
|
|
|
|
RUN unattended-upgrade
|
2019-07-09 09:03:55 +00:00
|
|
|
|
|
|
|
|
WORKDIR /code
|
2024-11-11 21:05:34 +00:00
|
|
|
ENV PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:/code/cmake-3.27.3-linux-x86_64/bin:/opt/miniconda/bin:${PATH}
|
2019-07-09 09:03:55 +00:00
|
|
|
|
|
|
|
|
# Prepare onnxruntime repository & build onnxruntime with TensorRT
|
2019-11-07 00:54:10 +00:00
|
|
|
RUN git clone --single-branch --branch ${ONNXRUNTIME_BRANCH} --recursive ${ONNXRUNTIME_REPO} onnxruntime &&\
|
2022-04-29 20:04:26 +00:00
|
|
|
/bin/sh onnxruntime/dockerfiles/scripts/install_common_deps.sh &&\
|
2022-01-21 21:20:53 +00:00
|
|
|
trt_version=${TRT_VERSION:0:3} &&\
|
2022-04-29 20:04:26 +00:00
|
|
|
/bin/sh onnxruntime/dockerfiles/scripts/checkout_submodules.sh ${trt_version} &&\
|
|
|
|
|
cd onnxruntime &&\
|
2023-03-27 21:46:04 +00:00
|
|
|
/bin/sh build.sh --allow_running_as_root --parallel --build_shared_lib --cuda_home /usr/local/cuda --cudnn_home /usr/lib/x86_64-linux-gnu/ --use_tensorrt --tensorrt_home /usr/lib/x86_64-linux-gnu/ --config Release --build_wheel --skip_tests --skip_submodule_sync --cmake_extra_defines '"CMAKE_CUDA_ARCHITECTURES='${CMAKE_CUDA_ARCHITECTURES}'"' &&\
|
2019-07-09 09:03:55 +00:00
|
|
|
pip install /code/onnxruntime/build/Linux/Release/dist/*.whl &&\
|
2022-08-16 21:13:05 +00:00
|
|
|
cd ..
|