-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.colmap
216 lines (188 loc) · 8.45 KB
/
Dockerfile.colmap
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
210
211
212
213
214
215
216
ARG CUDA_IMAGE_TAG=11.8.0
ARG OS_VERSION=22.04
ARG USER_ID=1000
ARG PYTHON_VERSION=3.10
ARG PYTORCH_VERSION=1.13.1
ARG CUDA=11.7
#
# Docker builder stage.
#
FROM dawars/pytorch:py${PYTHON_VERSION}-torch${PYTORCH_VERSION}-cu${CUDA} as builder
ARG COLMAP_GIT_COMMIT=54f6f75f088174d6bbfc20be0e3a494936fa5928
ARG CUDA_ARCHITECTURES=86;80;75
ENV QT_XCB_GL_INTEGRATION=xcb_egl
# Prevent stop building ubuntu at time zone selection.
ENV DEBIAN_FRONTEND=noninteractive
USER root
WORKDIR /workspace
# Prepare and empty machine for building.
RUN apt-get update && \
apt-get install -y --no-install-recommends --no-install-suggests \
git \
ninja-build \
build-essential \
libfreeimage-dev \
libflann-dev \
libmetis-dev \
libgoogle-glog-dev \
libgtest-dev \
libsqlite3-dev \
libglew-dev \
qtbase5-dev \
libqt5opengl5-dev \
libcgal-dev \
libsuitesparse-dev \
libhdf5-dev \
libeigen3-dev libboost-all-dev
ARG CUDA_ARCHITECTURES=61;86;80;75
# fix runtime issue libstdc++.so.6: version `GLIBCXX_3.4.30' not found
RUN conda install conda-forge::freeimage
RUN python -m pip install cmake && cmake --version
# Build and install COLMAP.
RUN git clone https://github.com/dawars/ceres-solver.git --recursive -b 2.2 && \
cd ceres-solver && \
mkdir build && \
cd build && \
cmake .. -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CUDA_ARCHITECTURES=$CUDA_ARCHITECTURES \
-DCMAKE_INSTALL_PREFIX=/ceres_installed && \
ninja install && \
cp -r /ceres_installed/* /usr/local/
RUN /workspace/ceres-solver/build/bin/simple_bundle_adjuster /workspace/ceres-solver/data/problem-16-22106-pre.txt
# RUN cd /workspace/ceres-solver/build/ && CUDA_LAUNCH_BLOCKING=1 ctest
ENV LD_LIBRARY_PATH="/opt/conda/lib:${LD_LIBRARY_PATH}"
# Build and install COLMAP.
RUN git clone https://github.com/dawars/colmap.git && \
cd colmap && \
git checkout 54f6f75f088174d6bbfc20be0e3a494936fa5928 && \
mkdir build && \
cd build && \
cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="/opt/conda/lib;/opt/conda/include;/opt/conda/" \
-DCMAKE_CUDA_ARCHITECTURES=${CUDA_ARCHITECTURES} \
-DCUDA_ENABLED=ON \
-DCMAKE_INSTALL_PREFIX=/colmap_installed \
-DBUILD_TESTING=ON \
-DGUI_ENABLED=OFF && \
ninja install && \
cp -r /colmap_installed/* /usr/local/
# -DCMAKE_PREFIX_PATH="/opt/conda/lib;/opt/conda/include;/opt/conda/" \
# -DFREEIMAGE_INCLUDE_DIR_HINTS=/opt/conda/include \
# -DFREEIMAGE_LIBRARY_DIR_HINTS=/opt/conda/lib \
RUN python -m pip install git+https://github.com/cvg/pyceres.git # needed for extra functionality in pycolmap
RUN cd colmap/pycolmap && \
pip install "pybind11[global]" && \
python -m pip wheel --config-settings=cmake.define.CMAKE_PREFIX_PATH="/opt/conda/lib;/opt/conda/include;/opt/conda/" \
-vv . -w . \
--config-settings=cmake.define.CMAKE_CUDA_ARCHITECTURES=${CUDA_ARCHITECTURES} \
--config-settings=cmake.define.CUDA_ENABLED=ON \
&& ls -l && \
python -m pip install pycolmap-3.11.0.dev0-cp310-cp310-linux_x86_64.whl # install for pixsfm build dependency
# RUN git clone --recursive https://github.com/dawars/pixel-perfect-sfm.git -b colmap-3.9 && \
# cd pixel-perfect-sfm && \
# git checkout 1fab153355305e8fcd1166609e7052565cc7be18 && \
# python -m pip wheel -v . -w . --config-settings=cmake.define.CMAKE_PREFIX_PATH="/opt/conda/lib;/opt/conda/include;/opt/conda/" \
# --config-settings=cmake.define.CMAKE_CUDA_ARCHITECTURES=${CUDA_ARCHITECTURES} \
# --config-settings=cmake.define.CUDA_ENABLED=ON
# RUN cd pixel-perfect-sfm && \
# mkdir build-exe && \
# cd build-exe && \
# cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug \
# -DBUILD_TESTING=OFF \
# -DCMAKE_CUDA_ARCHITECTURES=${CUDA_ARCHITECTURES} \
# -DCMAKE_INSTALL_PREFIX=/pixsfm_installed && \
# ninja install
#
RUN git clone https://github.com/colmap/glomap.git && \
cd glomap && \
git checkout d41b747407b6c5ce564e3936d0f2f2ea52f89dae && \
mkdir build && \
cd build && \
cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="/opt/conda/lib;/opt/conda/include;/opt/conda/" \
-DCMAKE_CUDA_ARCHITECTURES=${CUDA_ARCHITECTURES} \
-DCUDA_ENABLED=ON \
-DCMAKE_INSTALL_PREFIX=/glomap_installed \
-DBUILD_TESTING=ON \
-DGUI_ENABLED=OFF && \
ninja && ninja install
# Docker runtime stage.
FROM dawars/pytorch:py${PYTHON_VERSION}-torch${PYTORCH_VERSION}-cu${CUDA} as runtime
ARG CUDA_ARCHITECTURES=86;80;75
USER root
# Minimal dependencies to run COLMAP binary compiled in the builder stage.
# Note: this reduces the size of the final image considerably, since all the
# build dependencies are not needed.
RUN apt-get update && \
apt-get install -y --no-install-recommends --no-install-suggests \
libsuitesparse-dev \
libfreeimage-dev \
libeigen3-dev \
libc6 \
libgcc-s1 \
libmetis-dev \
libgl1 \
libglew2.2 \
libgoogle-glog-dev \
libhdf5-dev \
libopencv-dev libopencv-contrib-dev libarpack++2-dev libarpack2-dev libsuperlu-dev libboost-all-dev \
&& \
rm -rf /var/lib/apt/lists/*
# libboost-filesystem1.74.0 \
# libboost-program-options1.74.0 \
# Copy all files from /colmap_installed/ in the builder stage to /usr/local/ in
# the runtime stage. This simulates installing COLMAP in the default location
# (/usr/local/), which simplifies environment variables. It also allows the user
# of this Docker image to use it as a base image for compiling against COLMAP as
# a library. For instance, CMake will be able to find COLMAP easily with the
# command: find_package(COLMAP REQUIRED).
COPY --from=builder /ceres_installed/ /usr/local/
COPY --from=builder /colmap_installed/ /usr/local/
COPY --from=builder /glomap_installed/ /usr/local/
COPY --from=builder /workspace/colmap/pycolmap/pycolmap-3.11.0.dev0-cp310-cp310-linux_x86_64.whl /tmp/
COPY ./pystereoglue-0.1-cp310-cp310-linux_x86_64.whl /tmp/
COPY ./pixelstitch-0.1.5-py3-none-any.whl /tmp/
RUN python -m pip install /tmp/pystereoglue-0.1-cp310-cp310-linux_x86_64.whl \
/tmp/pixelstitch-0.1.5-py3-none-any.whl
# fix runtime issue libstdc++.so.6: version `GLIBCXX_3.4.30' not found
RUN conda install conda-forge::freeimage
RUN python -m pip install cmake && cmake --version && \
python -m pip install pyceres && \
python -m pip install pycolmap && \
python -m pip install git+https://github.com/Dawars/Hierarchical-Localization.git@d3adfc28f9ed162ed714a986bf4cf6025214f162 && \
rm -r /tmp/*.whl # /tmp/pixsfm-1.0.0-cp310-cp310-linux_x86_64.whl /tmp/pycolmap-3.11.0.dev0-cp310-cp310-linux_x86_64.whl
# detector free sfm
RUN python -m pip install pytorch-lightning>=2.3.3 ray opencv_python \
yacs>=0.1.8 joblib einops kornia>=0.7.3 timm>=0.3.2 hydra-core omegaconf wandb \
rich natsort torchmetrics albumentations tqdm matplotlib pylint loguru==0.5.3 scipy
RUN pip install -U openmim && \
mim install mmengine && \
mim install mmcv && \
python -c 'from mmengine.utils.dl_utils import collect_env;print(collect_env())'
RUN pip install git+https://github.com/Parskatt/RoMa.git \
git+https://github.com/facebookresearch/vggsfm.git \
git+https://github.com/jatentaki/unets.git@af4d574c13b3f137115394e714522b815fc6a417 \
git+https://github.com/jatentaki/torch-dimcheck.git@1b141ec38101500c59ae11ddb628e2fa3e40f18e \
git+https://github.com/jatentaki/torch-localize.git@f6dc5818ece911b6fed5bbdc3ce8aa2e60322116 \
pydegensac scikit-image
# vggsfm
#
# RUN conda install -c fvcore -c iopath -c conda-forge fvcore iopath && \
# conda install pytorch3d::pytorch3d xformers::xformers conda-forge::scikit-learn && \
# --upgrade && \
RUN conda install xformers::xformers
RUN pip install omegaconf hydra-core opencv-python einops visdom tqdm && \
pip install accelerate==0.24.0 && \
pip install git+https://github.com/jytime/LightGlue.git # && \
pip install poselib
# mast3r
RUN python -m pip install -e "git+https://github.com/cvg/GeoCalib#egg=geocalib"
RUN conda install -y -c conda-forge faiss-gpu && pip install cython trimesh gradio roma "huggingface-hub[torch]>=0.22" \
"pyglet<2" einops poselib fast_pytorch_kmeans
ENV LD_LIBRARY_PATH="/opt/conda/lib:${LD_LIBRARY_PATH}"
ENV PATH="/tmp/.local/bin:${PATH}"
RUN chown -R "${USER_ID}" /programs
USER ${USER_ID}
# Change working directory
WORKDIR /workspace