From 45d003c2e943744ac4c8e8a078c1a2faed63ba1c Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 27 Jan 2025 15:19:19 +0100 Subject: [PATCH] Moved onnx build to main dockerfile. --- README.md | 18 ++++++++++++++++++ dockerfile | 16 +++++++++++++++- extras/ros/dockerfile | 17 ----------------- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 0d4167b..c2f9e8c 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,24 @@ Fast triangulation of multiple persons from multiple camera views. cd RapidPoseTriangulation/ ``` +- Enable gpu-access while building docker images: + ```bash + # Open file: + sudo nano /etc/docker/daemon.json + # Add: + { + "default-runtime": "nvidia", + "runtimes": { + "nvidia": { + "path": "nvidia-container-runtime", + "runtimeArgs": [] + } + } + } + # Restart docker + sudo systemctl restart docker + ``` + - Build docker container: ```bash docker build --progress=plain -t rapidposetriangulation . diff --git a/dockerfile b/dockerfile index 51e1b78..9515a37 100644 --- a/dockerfile +++ b/dockerfile @@ -21,7 +21,21 @@ RUN apt-get update && apt-get install -y --no-install-recommends swig RUN apt-get update && apt-get install -y --no-install-recommends libopencv-dev # Install ONNX runtime -RUN pip3 install --upgrade --no-cache-dir onnxruntime-gpu +# See: https://github.com/microsoft/onnxruntime/blob/main/dockerfiles/Dockerfile.tensorrt +RUN pip3 uninstall -y onnxruntime-gpu +RUN git clone --recursive --depth=1 --branch=v1.20.1 https://github.com/Microsoft/onnxruntime.git +ENV PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:/cmake-3.30.1-linux-x86_64/bin:${PATH} +ARG CMAKE_CUDA_ARCHITECTURES=75;80;90 +ENV TRT_VERSION=10.5.0.18 +RUN /bin/sh onnxruntime/dockerfiles/scripts/install_common_deps.sh +RUN /bin/sh onnxruntime/dockerfiles/scripts/checkout_submodules.sh ${trt_version} +RUN ls +RUN cd onnxruntime && \ + /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}'"' +RUN cd onnxruntime && pip install build/Linux/Release/dist/*.whl # Install skelda RUN pip3 install --upgrade --no-cache-dir scipy diff --git a/extras/ros/dockerfile b/extras/ros/dockerfile index 8420926..07de25d 100644 --- a/extras/ros/dockerfile +++ b/extras/ros/dockerfile @@ -1,23 +1,6 @@ FROM rapidposetriangulation WORKDIR / -# Install ONNX runtime -# See: https://github.com/microsoft/onnxruntime/blob/main/dockerfiles/Dockerfile.tensorrt -RUN pip3 uninstall -y onnxruntime-gpu -RUN git clone --recursive --depth=1 --branch=v1.20.1 https://github.com/Microsoft/onnxruntime.git -ENV PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:/cmake-3.30.1-linux-x86_64/bin:${PATH} -ARG CMAKE_CUDA_ARCHITECTURES=75;80;90 -ENV TRT_VERSION=10.5.0.18 -RUN /bin/sh onnxruntime/dockerfiles/scripts/install_common_deps.sh -RUN /bin/sh onnxruntime/dockerfiles/scripts/checkout_submodules.sh ${trt_version} -RUN ls -RUN cd onnxruntime && \ - /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}'"' -RUN cd onnxruntime && pip install build/Linux/Release/dist/*.whl - # Install ROS2 # https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html RUN apt-get update && apt-get install -y --no-install-recommends locales