1
- ARG BASE_BUILD_IMAGE=ghcr.io/watonomous/wato_monorepo/base:cuda11.7-humble-ubuntu22.04-devel
2
- ARG BASE_PROD_IMAGE=ghcr.io/watonomous/wato_monorepo/base:cuda11.7-humble-ubuntu22.04
3
- ARG BASE_PYTORCH_IMAGE=ghcr.io/watonomous/wato_monorepo/segformer_segmentation:latest
4
- # ################################ Build library ################################
1
+ ARG BASE_IMAGE=ghcr.io/watonomous/wato_monorepo/base:cuda12.0-humble-ubuntu22.04-devel
2
+ ARG RUNTIME_IMAGE=ghcr.io/watonomous/wato_monorepo/base:cuda12.0-humble-ubuntu22.04
3
+ ARG PADDLE_INFERENCE_BUILD_URL=ghcr.io/watonomous/perception_paddlepaddle_inference_build_cuda-12.0
4
+ # ############################### Build library ################################
5
+ FROM ${PADDLE_INFERENCE_BUILD_URL} as PADDLE_INFERENCE_BUILD
5
6
6
- FROM ${BASE_PYTORCH_IMAGE} as Segformer
7
+ # ############################### Source ################################
8
+ FROM ${BASE_IMAGE} as source
7
9
8
- # # ################################ Source ################################
9
-
10
-
11
- FROM ${BASE_BUILD_IMAGE} as source
12
10
WORKDIR ${AMENT_WS}/src
13
11
14
- # # Copy in source code
12
+ # Copy in the paddle inference library
13
+ RUN mkdir -p semantic_segmentation/src
14
+ COPY --from=PADDLE_INFERENCE_BUILD /paddle/paddle_inference_cuda120_build.tar /paddle/paddle_inference_cuda120_build.tar
15
+ RUN tar -xvf /paddle/paddle_inference_cuda120_build.tar -C /paddle/
16
+ RUN rm /paddle/paddle_inference_cuda120_build.tar
17
+
18
+ # Copy in source code
15
19
COPY src/perception/semantic_segmentation semantic_segmentation
16
- COPY src/wato_msgs/sample_msgs sample_msgs
17
- COPY --from=Segformer /mmsegmentation/model ${AMENT_WS}/src/semantic_segmentation/resource/model
20
+ COPY src/perception/perception_utils perception_utils
18
21
19
22
# Scan for rosdeps
20
23
RUN apt-get -qq update && rosdep update && \
@@ -25,43 +28,17 @@ RUN apt-get -qq update && rosdep update && \
25
28
26
29
27
30
# ################################ Dependencies ################################
28
- FROM ${BASE_BUILD_IMAGE } as dependencies
31
+ FROM ${BASE_IMAGE } as dependencies
29
32
30
- RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub
31
- RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub
32
-
33
- # Install system dependencies
34
- RUN apt-get update && apt-get install -y \
35
- git \
36
- python3-pip \
37
- ninja-build \
38
- libglib2.0-0 \
39
- libsm6 \
40
- libxrender-dev \
41
- libxext6 \
42
- libgl1-mesa-dev \
43
- libopencv-dev \
44
- && apt-get clean \
45
- && rm -rf /var/lib/apt/lists/*
46
-
47
- # Install Segformer dependencies
48
- # COPY --from=Segformer /tmp/pip_install_list.txt /tmp/pip_install_list.txt torchaudio==0.13.1
49
- RUN pip install torch==1.13.1+cu116 \
50
- torchvision==0.14.1+cu116 --extra-index-url https://download.pytorch.org/whl/cu116 \
51
- cython \
52
- https://download.openmmlab.com/mmcv/dist/cu117/torch1.13.0/mmcv-2.0.0rc4-cp310-cp310-manylinux1_x86_64.whl
53
- RUN apt update && apt install -y ros-humble-cv-bridge
54
-
55
- WORKDIR /mmsegmentation
56
- COPY --from=Segformer /mmsegmentation /mmsegmentation
57
- RUN pip install -r requirements.txt --no-cache-dir -e . && pip uninstall numpy -y && pip install numpy==1.26.4
33
+ RUN apt update && apt install -y tensorrt ros-humble-cv-bridge libopencv-dev
58
34
59
35
# Install Rosdep requirements
60
36
COPY --from=source /tmp/colcon_install_list /tmp/colcon_install_list
61
37
RUN apt install -qq -y --no-install-recommends $(cat /tmp/colcon_install_list)
62
38
63
39
# Copy in source code from source stage
64
40
WORKDIR ${AMENT_WS}
41
+ COPY --from=source /paddle /paddle
65
42
COPY --from=source ${AMENT_WS}/src src
66
43
67
44
# Dependency Cleanup
@@ -72,10 +49,6 @@ RUN apt-get -qq autoremove -y && apt-get -qq autoclean && apt-get -qq clean && \
72
49
# ############################### Build ################################
73
50
FROM dependencies as build
74
51
75
-
76
- ENV FORCE_CUDA="1"
77
-
78
-
79
52
# Build ROS2 packages
80
53
WORKDIR ${AMENT_WS}
81
54
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
@@ -86,30 +59,43 @@ RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
86
59
COPY docker/wato_ros_entrypoint.sh ${AMENT_WS}/wato_ros_entrypoint.sh
87
60
88
61
# Add runtime libraries to path
89
- ENV CUDNN_DIR=/mmsegmentation/cuda
90
- ENV CV2_CUDABACKEND=0
91
62
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${AMENT_WS}/install/semantic_segmentation/lib/
92
63
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
93
64
94
65
ENTRYPOINT ["./wato_ros_entrypoint.sh" ]
95
66
96
- # ############################### Prod ################################
97
- FROM build as deploy
67
+ # ################################ Prod ################################
68
+ FROM ${RUNTIME_IMAGE} as deploy
69
+
98
70
99
71
# Install runtime libs
100
72
RUN apt-get update && apt-get install -y \
101
- ros-humble-cv-bridge
73
+ ros-humble-cv-bridge \
74
+ tensorrt
102
75
76
+ # Copy the compiled binary to the runtime image
77
+ COPY --from=build ${AMENT_WS} ${AMENT_WS}
103
78
104
79
WORKDIR ${AMENT_WS}
105
80
81
+ # Copy in the paddle inference library
106
82
RUN mkdir -p install/semantic_segmentation/lib/
83
+ COPY --from=PADDLE_INFERENCE_BUILD /paddle/paddle_inference_cuda120_build.tar install/semantic_segmentation/lib/paddle_inference_cuda120_build.tar
84
+ RUN tar -xvf install/semantic_segmentation/lib/paddle_inference_cuda120_build.tar -C install/semantic_segmentation/lib
85
+ RUN rm install/semantic_segmentation/lib/paddle_inference_cuda120_build.tar
86
+
107
87
# Add runtime libraries to path
108
88
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${AMENT_WS}/install/semantic_segmentation/lib/
109
89
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
90
+ ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${AMENT_WS}/install/semantic_segmentation/lib/paddle_inference_cuda120_build/paddle_inference_install_dir/paddle/lib/
91
+
92
+ ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${AMENT_WS}/install/semantic_segmentation/lib/paddle_inference_cuda120_build/paddle_inference_install_dir/third_party/install/cryptopp/lib/
93
+ ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${AMENT_WS}/install/semantic_segmentation/lib/paddle_inference_cuda120_build/paddle_inference_install_dir/third_party/install/mkldnn/lib/
94
+ ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${AMENT_WS}/install/semantic_segmentation/lib/paddle_inference_cuda120_build/paddle_inference_install_dir/third_party/install/mklml/lib/
110
95
111
96
COPY docker/wato_ros_entrypoint.sh ${AMENT_WS}/wato_ros_entrypoint.sh
112
97
ENTRYPOINT ["./wato_ros_entrypoint.sh" ]
98
+
113
99
# Source Cleanup and Security Setup
114
100
RUN chown -R $USER:$USER ${AMENT_WS}
115
101
RUN rm -rf src/*
0 commit comments