|
| 1 | +FROM rwthika/ros2-torch:jazzy-ros-base-torch2.5.0 |
| 2 | + |
| 3 | +MAINTAINER Jesse Morris "jesse.morris@sydney.edu.au" |
| 4 | + |
| 5 | + |
| 6 | +# To avoid tzdata asking for geographic location... |
| 7 | +ENV DEBIAN_FRONTEND=noninteractive |
| 8 | + |
| 9 | +#Install build dependencies |
| 10 | +RUN apt-get update && apt-get upgrade -y --allow-downgrades --no-install-recommends apt-utils |
| 11 | +RUN apt-get update && apt-get install -y --allow-downgrades git cmake build-essential pkg-config |
| 12 | +# Install xvfb to provide a display to container for GUI realted testing. |
| 13 | +RUN apt-get update && apt-get install -y --allow-downgrades xvfb |
| 14 | + |
| 15 | +# In the arm64 version of the base image we do not have the nvidia-cuda-development toolkit |
| 16 | +# as explained https://github.com/ika-rwth-aachen/docker-ros-ml-images/issues/16 |
| 17 | +# this contains nvcc (ie we dont have it) |
| 18 | +# we need nvcc to build opencv with cuda |
| 19 | +# add extra nvidia container apt repository (otherwise we cannot find nvidia-cuda-toolkit) |
| 20 | +RUN curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \ |
| 21 | + && curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \ |
| 22 | + sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \ |
| 23 | + sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list |
| 24 | + |
| 25 | + |
| 26 | +#NOTE: both nvidia-cuda-toolkit and cuda-toolkit are needed (particularly for header files) |
| 27 | +RUN apt-get update \ |
| 28 | + && apt-get install -y \ |
| 29 | + python3-pip \ |
| 30 | + openssh-client \ |
| 31 | + software-properties-common \ |
| 32 | + nano \ |
| 33 | + vim \ |
| 34 | + clang-format \ |
| 35 | + nvidia-cuda-toolkit \ |
| 36 | + cuda-toolkit \ |
| 37 | + libnvinfer-dev \ |
| 38 | + libnvonnxparsers-dev \ |
| 39 | + tensorrt-dev \ |
| 40 | + && pip3 install black pre-commit \ |
| 41 | + && rm -rf /var/lib/apt/lists/* |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | +# # ROS installs |
| 46 | +RUN apt-get update && apt-get install -y \ |
| 47 | + ros-jazzy-ros2cli-common-extensions \ |
| 48 | + ros-jazzy-cv-bridge \ |
| 49 | + ros-jazzy-vision-opencv \ |
| 50 | + ros-jazzy-pcl-ros \ |
| 51 | + ros-jazzy-rmw-fastrtps-cpp \ |
| 52 | + ros-jazzy-rmw-zenoh-cpp \ |
| 53 | + ros-jazzy-image-transport \ |
| 54 | + libpcl-conversions-dev |
| 55 | + |
| 56 | +# other deps |
| 57 | +# RUN apt-get install libpng++-dev |
| 58 | +# is libpng-dev different from libpng++? I think not available as a apt for aarm64 |
| 59 | +# RUN apt-get install libpng-dev |
| 60 | + |
| 61 | +RUN python3 -m pip install pylatex evo setuptools pre-commit scipy argcomplete black pre-commit |
| 62 | + |
| 63 | +# Install glog, gflags |
| 64 | +RUN apt-get update && apt-get install -y libgflags2.2 libgflags-dev libgoogle-glog-dev |
| 65 | + |
| 66 | +# Install xvfb to provide a display to container for GUI realted testing. |
| 67 | +# vtk is needed for OpenCV to build its viz module (from contrib!) |
| 68 | +RUN apt-get update && apt-get install -y xvfb python3-dev python3-setuptools libvtk9-dev |
| 69 | + |
| 70 | +RUN pip3 install setuptools pre-commit scipy matplotlib argcomplete |
| 71 | + |
| 72 | +# install CSparse |
| 73 | +RUN DEBIAN_FRONTEND=noninteractive apt install -y libsuitesparse-dev |
| 74 | + |
| 75 | +RUN python3 -m pip install "ultralytics==8.3.0" "numpy<2.0" "opencv-python<5.0" |
| 76 | +RUN python3 -m pip install https://github.com/ultralytics/assets/releases/download/v0.0.0/onnxruntime_gpu-1.23.0-cp310-cp310-linux_aarch64.whl |
| 77 | + |
| 78 | +# Parallelism C++ for CPU |
| 79 | +RUN apt-get update && apt-get install -y libboost-all-dev libtbb-dev |
| 80 | + |
| 81 | +WORKDIR /root/ |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | +# Install OpenCV for Ubuntu |
| 86 | +RUN apt-get update && apt-get install -y \ |
| 87 | + unzip \ |
| 88 | + libjpeg-dev libpng-dev libpng++-dev libtiff-dev libgtk2.0-dev \ |
| 89 | + libatlas-base-dev gfortran |
| 90 | + |
| 91 | + |
| 92 | +RUN git clone https://github.com/opencv/opencv.git |
| 93 | +RUN cd opencv && \ |
| 94 | + git checkout tags/4.10.0 && \ |
| 95 | + mkdir build |
| 96 | + |
| 97 | +RUN git clone https://github.com/opencv/opencv_contrib.git |
| 98 | +RUN cd opencv_contrib && \ |
| 99 | + git checkout tags/4.10.0 |
| 100 | + |
| 101 | +# on aarch64 there is no binary for nlohmann-json3 |
| 102 | +RUN git clone https://github.com/nlohmann/json.git |
| 103 | +RUN cd json && mkdir build && \ |
| 104 | + cd build && \ |
| 105 | + cmake .. && make -j$(nproc) install |
| 106 | + |
| 107 | +# OpenCV looks for the cuDNN version in cudnn_version.h, but it's been renamed to cudnn_version_v8.h |
| 108 | +RUN ln -sfnv /usr/include/$(uname -i)-linux-gnu/cudnn_version_v*.h /usr/include/$(uname -i)-linux-gnu/cudnn_version.h |
| 109 | + |
| 110 | +# IMPORTANT: must specify CXX_17 version. Default is c++11 which will cause compilation issues |
| 111 | +# On aarch64 we can enable NEON for CPU level optimisations |
| 112 | +# It is vital we use gcc-11 as otheriwise we cannot compile the cuda level code (ie. CUDA 12.9) |
| 113 | +RUN cd opencv/build && \ |
| 114 | + cmake -DCMAKE_BUILD_TYPE=Release \ |
| 115 | + -DCMAKE_INSTALL_PREFIX=/usr/local \ |
| 116 | + -DCMAKE_CXX_STANDARD=17 \ |
| 117 | + -D BUILD_opencv_python=OFF \ |
| 118 | + -D BUILD_opencv_python2=OFF \ |
| 119 | + -D BUILD_opencv_python3=ON \ |
| 120 | + -D WITH_CUDA=ON \ |
| 121 | + -D WITH_CUDNN=ON \ |
| 122 | + -D INSTALL_CUDA_LIBS=OFF \ |
| 123 | + -D CUDA_ARCH_PTX= \ |
| 124 | + -D CUDA_ARCH_BIN=8.7 \ |
| 125 | + -D CUDNN_INCLUDE_DIR=/usr/include/$(uname -i)-linux-gnu \ |
| 126 | + -D OPENCV_DNN_CUDA=ON \ |
| 127 | + -D ENABLE_FAST_MATH=ON \ |
| 128 | + -D CUDA_FAST_MATH=ON \ |
| 129 | + -D WITH_VTK=ON \ |
| 130 | + -D WITH_CUFFT=ON \ |
| 131 | + -D WITH_CUBLAS=ON \ |
| 132 | + -D WITH_TBB=ON \ |
| 133 | + -DENABLE_NEON=ON \ |
| 134 | + -D BUILD_TESTS=OFF \ |
| 135 | + -D BUILD_PERF_TESTS=OFF \ |
| 136 | + -D BUILD_opencv_ts=OFF \ |
| 137 | + -D BUILD_opencv_sfm=OFF \ |
| 138 | + -D BUILD_JAVA=OFF \ |
| 139 | + -DOPENCV_EXTRA_MODULES_PATH=/root/opencv_contrib/modules .. && \ |
| 140 | + make -j$(nproc) install |
| 141 | + |
| 142 | +RUN git clone https://github.com/MIT-SPARK/config_utilities.git |
| 143 | +RUN cd config_utilities/config_utilities && mkdir build && \ |
| 144 | + cd build && \ |
| 145 | + cmake .. && make -j$(nproc) install |
| 146 | + |
| 147 | + |
| 148 | + |
| 149 | +# Install GTSAM |
| 150 | +RUN git clone https://github.com/borglab/gtsam.git |
| 151 | +RUN cd gtsam && \ |
| 152 | + git fetch && \ |
| 153 | + git checkout tags/4.2.0 && \ |
| 154 | + mkdir build && \ |
| 155 | + cd build && \ |
| 156 | + cmake -DCMAKE_INSTALL_PREFIX=/usr/local \ |
| 157 | + -DGTSAM_USE_SYSTEM_EIGEN=ON \ |
| 158 | + -DGTSAM_BUILD_TESTS=OFF -DGTSAM_BUILD_EXAMPLES_ALWAYS=OFF -DCMAKE_BUILD_TYPE=Release -DGTSAM_BUILD_UNSTABLE=ON -DGTSAM_POSE3_EXPMAP=ON -DGTSAM_ROT3_EXPMAP=ON -DGTSAM_TANGENT_PREINTEGRATION=OFF .. && \ |
| 159 | + make -j$(nproc) install |
| 160 | + |
| 161 | + |
| 162 | +# Install Open_GV |
| 163 | +RUN git clone https://github.com/MIT-SPARK/opengv |
| 164 | +RUN cd opengv && \ |
| 165 | + mkdir build |
| 166 | +RUN cd opengv/build && \ |
| 167 | + cmake -DCMAKE_BUILD_TYPE=Release \ |
| 168 | + -DCMAKE_INSTALL_PREFIX=/usr/local \ |
| 169 | + .. && make -j$(nproc) install |
| 170 | + |
| 171 | + |
| 172 | +RUN echo 'export RMW_IMPLEMENTATION=rmw_zenoh_cpp' >> ~/.bashrc |
| 173 | + |
| 174 | +RUN mkdir -p /home/user/dev_ws/src/core |
| 175 | +RUN mkdir -p /home/user/dev_ws/src/third_parties |
| 176 | +RUN mkdir -p /home/user/upstream_ws/src |
| 177 | + |
| 178 | +SHELL ["/bin/bash", "-c"] |
| 179 | + |
| 180 | +RUN source /opt/ros/jazzy/setup.bash |
| 181 | + |
| 182 | +WORKDIR /home/user/dev_ws |
0 commit comments