-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile_orbslam3
209 lines (184 loc) · 8.44 KB
/
Dockerfile_orbslam3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
FROM nvidia/cudagl:11.3.1-devel-ubuntu18.04
#############################################
# SECTION 0: Install cuDNN #
#############################################
ENV NV_CUDNN_VERSION=8.2.0.53
ENV NV_CUDNN_PACKAGE="libcudnn8=$NV_CUDNN_VERSION-1+cuda11.3" \
NV_CUDNN_PACKAGE_DEV="libcudnn8-dev=$NV_CUDNN_VERSION-1+cuda11.3" \
NV_CUDNN_PACKAGE_NAME="libcudnn8"
RUN apt-get update && apt-get install -y --no-install-recommends \
${NV_CUDNN_PACKAGE} \
${NV_CUDNN_PACKAGE_DEV} \
&& apt-mark hold ${NV_CUDNN_PACKAGE_NAME} \
&& rm -rf /var/lib/apt/lists/*
#########################################
# SECTION 1: Essentials #
#########################################
# Run apt-get (dkpg) without interactive dialogue
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
vim git curl wget yasm cmake unzip pkg-config \
checkinstall build-essential ca-certificates \
software-properties-common apt-utils bash-completion \
libeigen3-dev \
&& apt-get upgrade -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Setup locale language config
RUN apt-get update && apt-get install -y --no-install-recommends locales \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& locale-gen "en_US.UTF-8" \
&& update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 \
&& ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime # Set timezone
ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
#########################################
# SECTION 1.5: Install ROS melodic #
#########################################
RUN sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' \
&& apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 \
&& curl -sSL 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' | apt-key add - \
&& apt-get update && apt-get install -y ros-melodic-desktop \
&& apt-get install -y python-rosdep \
&& rosdep init && rosdep update \
&& apt-get install -y python-rosinstall python-rosinstall-generator python-wstool build-essential \
&& sh -c 'echo "deb http://packages.ros.org/ros/ubuntu `lsb_release -sc` main" > /etc/apt/sources.list.d/ros-latest.list' \
&& wget http://packages.ros.org/ros.key -O - | sudo apt-key add - \
&& apt-get update && apt-get install -y python-catkin-tools \
&& echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV ROS_DISTRO melodic
#########################################
# SECTION 2: Setup Image Libraries #
#########################################
RUN apt-get update && apt-get install -y --no-install-recommends \
zlib1g-dev libjpeg-dev libpng-dev xvfb ffmpeg xorg-dev \
xorg-dev libboost-all-dev libsdl2-dev swig \
libblas-dev liblapack-dev \
libopenblas-base libatlas-base-dev graphviz \
&& apt-get upgrade -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
######################################
# SECTION 3: OpenCV packages #
######################################
ARG OPENCV_PATH=/usr/local/share/opencv
ARG OPENCV_CONTRIB_PATH=/usr/local/share/opencv_contrib
ARG OPENCV_VERSION=4.4.0
RUN apt-get update && apt-get install -y --no-install-recommends \
libgtk-3-dev \
libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev \
gfortran openexr libatlas-base-dev python3-dev python3-numpy \
libtbb2 libtbb-dev libdc1394-22-dev libopenexr-dev \
libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN echo -e "Install OPENCV Contrib\n\n" && \
wget -O opencv_contrib.zip "https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip" && \
unzip opencv_contrib.zip && \
mv opencv_contrib-* "$OPENCV_CONTRIB_PATH" && \
rm opencv_contrib.zip
RUN echo -e "Install OPENCV \n\n" && \
wget -O opencv.zip "https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip" && \
unzip opencv.zip && \
mv opencv-* "$OPENCV_PATH" && \
rm opencv.zip
RUN echo -e "Make / Build OPENCV\n\n" && \
mkdir -p "${OPENCV_PATH}/build" && \
cd "${OPENCV_PATH}/build" && \
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX="$OPENCV_PATH" \
-D OPENCV_EXTRA_MODULES_PATH="${OPENCV_CONTRIB_PATH}/modules" \
-D WITH_CUDA=ON \
-D CUDA_ARCH_BIN=6.1,7.5 \
-D CUDA_ARCH_PTX="" \
-D WITH_CUDNN=ON \
-D OPENCV_DNN_CUDA=ON \
-D WITH_CUBLAS=ON \
-D CUDA_FAST_MATH=ON \
-D ENABLE_FAST_MATH=ON \
-D WITH_TBB=ON \
-D WITH_V4L=ON \
-D WITH_QT=OFF \
-D WITH_OPENGL=ON \
-D BUILD_opencv_cudacodec=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D BUILD_opencv_python2=OFF \
-D BUILD_NEW_PYTHON_SUPPORT=ON \
-D PYTHON3_EXECUTABLE=$(which python3) \
-D PYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D OPENCV_PYTHON3_INSTALL_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-D BUILD_EXAMPLES=OFF \
.. && \
make -j$(nproc) && make install
ENV OpenCV_DIR=/usr/local/share/opencv/build
######################################
# SECTION 3.5: Install Pangolin #
######################################
RUN apt-get update && apt-get install -y --no-install-recommends \
libgtk-3-dev python-dev libgl1-mesa-dev libglew-dev libpython2.7-dev \
libeigen3-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# set up directories
RUN mkdir /slamdoom && mkdir /slamdoom/tmp && mkdir /slamdoom/libs
# Build Pangolin
RUN cd /slamdoom/libs && git clone https://github.com/stevenlovegrove/Pangolin pangolin \
&& cd /slamdoom/libs/pangolin && mkdir build && cd build \
&& cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-std=c++11 .. \
&& make -j$(nproc) && make install
######################################
# SECTION 4: Install librealsense #
######################################
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE \
|| apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE \
&& add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo $(lsb_release -cs) main" -u \
&& apt-get update && apt-get install -y \
librealsense2-dkms librealsense2-utils \
librealsense2-dev librealsense2-dbg \
ros-melodic-realsense2-camera ros-melodic-realsense2-description \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
#########################################
# SECTION 4.5: Install Python Libraries #
#########################################
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& python3 -m pip install --upgrade pip \
&& python3 -m pip install jupyter jupyter_contrib_nbextensions \
&& jupyter contrib nbextension install \
&& python3 -m pip install jupyter_nbextensions_configurator \
&& jupyter nbextensions_configurator enable \
&& jupyter nbextension enable codefolding/main \
&& mkdir /.local && chmod a+rwx /.local
######################################
# SECTION 5: Add running instruction #
######################################
# Set working directory to be repository directory
ENV REPOPATH /maya-slam
WORKDIR ${REPOPATH}
# Append the custom bashrc
COPY bashrc /tmp/
RUN cat /tmp/bashrc > /etc/bash.bashrc
# For CUDA library
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH}
# Tensorflow 2.4.1 CUDA library issue
RUN ln -s /usr/local/cuda-11.3/lib64/libcusolver.so.11 /usr/local/cuda-11.3/lib64/libcusolver.so.10
#ENTRYPOINT ["/ros_entrypoint.sh"]
#######################################
# SECTION 6: Additional installations #
#######################################
# Add ORB_SLAM3 path to ROS_PACKAGE_PATH
RUN echo 'export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/maya-slam/slam_algorithms/ORB_SLAM3/Examples_old/ROS' >> ~/.bashrc
#######################################
# SECTION 7: Helpful commands #
#######################################
ENV COMMANDTOCOMPILE="cd slam_algorithms/ORB_SLAM3 && ./build.sh && ./build_ros.sh"
ENV JUPYTERPORT="9000"
ENV COMMANDTORUNJUPYTER="jupyter notebook --no-browser --ip=0.0.0.0 --allow-root --port=${JUPYTERPORT} &"