-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.FiGS
More file actions
295 lines (260 loc) · 10.9 KB
/
Dockerfile.FiGS
File metadata and controls
295 lines (260 loc) · 10.9 KB
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# syntax=docker/dockerfile:1
# FiGS Docker Environment
# Based on official nerfstudio Dockerfile with FiGS-specific modifications
#
# Key differences from official nerfstudio:
# - numpy pinned to 1.26.4 (not just <2.0)
# - gsplat version configurable (default 1.5.3 for nbv-splat compatibility)
# - acados included for MPC-based control
# - gemsplat dependencies pre-installed
#
# IMPORTANT: gemsplat/rasterization_routines/rendering.py requires updates for gsplat 1.5.3:
# - fully_fused_projection returns 8 values (adds batch_ids as first element)
# - isect_tiles uses n_images/image_ids instead of n_cameras/camera_ids
# NOTE: UBUNTU_VERSION is not truly configurable — the runtime stage hardcodes
# version-specific library packages (e.g., libboost-filesystem1.74.0, libceres2,
# libgoogle-glog0v5) that are specific to Ubuntu 22.04 (Jammy).
ARG UBUNTU_VERSION=22.04
ARG NVIDIA_CUDA_VERSION=11.8.0
ARG CUDA_ARCHITECTURES=""
ARG GSPLAT_VERSION=1.5.3
ARG NERFSTUDIO_VERSION="main"
# === SOURCE STAGE ===
# Pull nerfstudio source either from local copy or git
FROM scratch AS source_copy
ONBUILD COPY . /tmp/nerfstudio
FROM alpine/git AS source_no_copy
ARG NERFSTUDIO_VERSION
ONBUILD RUN git clone --branch ${NERFSTUDIO_VERSION} --recursive https://github.com/nerfstudio-project/nerfstudio.git /tmp/nerfstudio
ARG NERFSTUDIO_VERSION
FROM source_${NERFSTUDIO_VERSION:+no_}copy AS source
# === BUILDER STAGE ===
FROM nvidia/cuda:${NVIDIA_CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION} AS builder
ARG CUDA_ARCHITECTURES
ARG NVIDIA_CUDA_VERSION
ARG UBUNTU_VERSION
ARG GSPLAT_VERSION
RUN if [ -z "$CUDA_ARCHITECTURES" ]; then \
echo ""; \
echo "ERROR: CUDA_ARCHITECTURES is not set."; \
echo "Set it to your GPU's compute capability, e.g.:"; \
echo " CUDA_ARCHITECTURES=\$(nvidia-smi --query-gpu=compute_cap --format=csv,noheader | head -1 | tr -d '.') docker compose build"; \
echo ""; \
exit 1; \
fi
ENV DEBIAN_FRONTEND=noninteractive
ENV QT_XCB_GL_INTEGRATION=xcb_egl
# System dependencies (same as official nerfstudio + acados deps)
# libxcrypt-dev, pkg-config, linux-libc-dev added for broader build compatibility
# NOTE: security.ubuntu.com removed to work around mirror inconsistency (404s for libexpat1).
# jammy-updates on archive.ubuntu.com includes all security patches.
RUN sed -i '/security.ubuntu.com/d' /etc/apt/sources.list && \
apt-get update && \
apt-get install -y --no-install-recommends --no-install-suggests \
git \
wget \
ninja-build \
build-essential \
pkg-config \
linux-libc-dev \
libboost-program-options-dev \
libboost-filesystem-dev \
libboost-graph-dev \
libboost-system-dev \
libeigen3-dev \
libflann-dev \
libfreeimage-dev \
libmetis-dev \
libgoogle-glog-dev \
libgtest-dev \
libsqlite3-dev \
libglew-dev \
qtbase5-dev \
libqt5opengl5-dev \
libcgal-dev \
libceres-dev \
python3.10-dev \
python3-pip \
cmake \
liblapack-dev \
libblas-dev \
&& rm -rf /var/lib/apt/lists/*
# CMake (same as official)
RUN wget https://github.com/Kitware/CMake/releases/download/v3.31.3/cmake-3.31.3-linux-x86_64.sh \
-q -O /tmp/cmake-install.sh \
&& chmod u+x /tmp/cmake-install.sh \
&& mkdir /opt/cmake-3.31.3 \
&& /tmp/cmake-install.sh --skip-license --prefix=/opt/cmake-3.31.3 \
&& rm /tmp/cmake-install.sh \
&& ln -s /opt/cmake-3.31.3/bin/* /usr/local/bin
# GLOMAP (same as official)
RUN git clone https://github.com/colmap/glomap.git && \
cd glomap && \
git checkout "1.0.0" && \
mkdir build && \
cd build && \
mkdir -p /build && \
cmake .. -GNinja "-DCMAKE_CUDA_ARCHITECTURES=${CUDA_ARCHITECTURES}" \
-DCMAKE_INSTALL_PREFIX=/build/glomap && \
ninja install -j1 && \
cd ~ && rm -rf /glomap
# COLMAP (same as official)
RUN git clone https://github.com/colmap/colmap.git && \
cd colmap && \
git checkout "3.9.1" && \
mkdir build && \
cd build && \
mkdir -p /build && \
cmake .. -GNinja "-DCMAKE_CUDA_ARCHITECTURES=${CUDA_ARCHITECTURES}" \
-DCMAKE_INSTALL_PREFIX=/build/colmap && \
ninja install -j1 && \
cd ~ && rm -rf /colmap
# Python dependencies - MODIFIED: pin numpy==1.26.4
RUN pip install --no-cache-dir --upgrade pip 'setuptools<70.0.0' && \
pip install --no-cache-dir \
torch==2.1.2+cu118 \
torchvision==0.16.2+cu118 \
numpy==1.26.4 \
--extra-index-url https://download.pytorch.org/whl/cu118
# Hierarchical-Localization with SuperGlue
# Using commit 936040e8 which has pycolmap 0.6.x compatibility (before 3.12+ requirement)
RUN git clone --recursive https://github.com/cvg/Hierarchical-Localization.git /opt/hloc && \
cd /opt/hloc && git checkout 936040e8d67244cc6c8c9d1667701f3ce87bf075 && \
git submodule update --init --recursive && \
python3.10 -m pip install --no-cache-dir . && \
# Keep SuperGlue and add to Python path
cp -r /opt/hloc/third_party/SuperGluePretrainedNetwork /usr/local/lib/python3.10/dist-packages/ && \
rm -rf /opt/hloc
# tiny-cuda-nn (requires --no-build-isolation to see installed torch)
# NVCC_APPEND_FLAGS allows building with newer GCC versions than CUDA 11.8 officially supports
RUN pip install --no-cache-dir ninja && \
TCNN_CUDA_ARCHITECTURES="${CUDA_ARCHITECTURES}" \
NVCC_APPEND_FLAGS="-allow-unsupported-compiler" \
pip install --no-cache-dir --no-build-isolation \
"git+https://github.com/NVlabs/tiny-cuda-nn.git@b3473c81396fe927293bdfd5a6be32df8769927c#subdirectory=bindings/torch"
# Additional Python deps (same as official)
RUN pip install --no-cache-dir pycolmap==0.6.1 pyceres==2.1 omegaconf==2.3.0
# nerfstudio from source (install BEFORE gsplat so we can override the version)
COPY --from=source /tmp/nerfstudio/ /tmp/nerfstudio
RUN pip install --no-cache-dir /tmp/nerfstudio numpy==1.26.4 && \
rm -rf /tmp/nerfstudio
# gsplat - MODIFIED: install AFTER nerfstudio to override its default version
# Use --extra-index-url so PyPI is still available for deps like jaxtyping
RUN export TORCH_CUDA_ARCH_LIST="$(echo "$CUDA_ARCHITECTURES" | tr ';' '\n' | awk '$0 > 70 {print substr($0,1,1)"."substr($0,2)}' | tr '\n' ' ' | sed 's/ $//')" && \
export MAX_JOBS=4 && \
pip install --no-cache-dir gsplat==${GSPLAT_VERSION} --extra-index-url https://docs.gsplat.studio/whl/pt21cu118
# === FiGS-SPECIFIC DEPENDENCIES ===
# FiGS misc dependencies (from install-serverside.sh lines 140-149)
RUN pip install --no-cache-dir \
albumentations \
"qpsolvers[open_source_solvers]" \
tabulate \
cython \
ipykernel \
ipympl \
rich \
"imageio[ffmpeg]" \
roma \
open3d
# gemsplat dependencies (from gemsplat/pyproject.toml)
# Pre-install these so container startup is fast
RUN pip install --no-cache-dir \
timm \
ftfy \
regex \
tqdm \
einops \
gdown \
matplotlib \
pillow
# torchtyping with --no-deps to avoid typeguard conflict with nerfstudio's tyro
RUN pip install --no-cache-dir --no-deps torchtyping
# CLIP from OpenAI (required by gemsplat)
RUN pip install --no-cache-dir --no-build-isolation git+https://github.com/openai/CLIP.git@dcba3cb2e2827b402d2701e7e1c7d9fed8a20ef1
# === ACADOS BUILD ===
# Build acados for MPC-based trajectory control
RUN git clone --branch v0.5.3 https://github.com/acados/acados.git /opt/acados && \
cd /opt/acados && \
git submodule update --init --recursive && \
mkdir -p build && \
cd build && \
cmake -DACADOS_WITH_QPOASES=ON -DCMAKE_INSTALL_PREFIX=/opt/acados .. && \
make install -j4 && \
pip install --no-cache-dir -e /opt/acados/interfaces/acados_template
# Set acados environment variables
ENV ACADOS_SOURCE_DIR=/opt/acados
ENV LD_LIBRARY_PATH=/opt/acados/lib:${LD_LIBRARY_PATH}
# Re-pin numpy after all installs (downstream packages may pull in numpy 2.x)
RUN pip install --no-cache-dir numpy==1.26.4
# Fix permissions
RUN chmod -R go=u /usr/local/lib/python3.10 && \
chmod -R go=u /build
# === RUNTIME STAGE ===
FROM nvidia/cuda:${NVIDIA_CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION} AS runtime
ARG CUDA_ARCHITECTURES
ARG NVIDIA_CUDA_VERSION
ARG UBUNTU_VERSION
ARG GSPLAT_VERSION
LABEL org.opencontainers.image.description="FiGS environment with nerfstudio, gsplat ${GSPLAT_VERSION}, and acados"
LABEL org.opencontainers.image.source="https://github.com/StanfordMSL/FiGS-Standalone"
RUN sed -i '/security.ubuntu.com/d' /etc/apt/sources.list && \
apt-get update && \
apt-get install -y --no-install-recommends --no-install-suggests \
libboost-filesystem1.74.0 \
libboost-program-options1.74.0 \
libc6 \
libceres2 \
libfreeimage3 \
libgcc-s1 \
libgl1 \
libglew2.2 \
libgoogle-glog0v5 \
libqt5core5a \
libqt5gui5 \
libqt5widgets5 \
python3.10 \
python3.10-dev \
build-essential \
python-is-python3 \
ffmpeg \
git \
liblapack3 \
libblas3 \
libopengl0 \
&& rm -rf /var/lib/apt/lists/*
# Copy build artifacts
COPY --from=builder /build/colmap/ /usr/local/
COPY --from=builder /build/glomap/ /usr/local/
COPY --from=builder /usr/local/lib/python3.10/dist-packages/ /usr/local/lib/python3.10/dist-packages/
COPY --from=builder /usr/local/bin/ns* /usr/local/bin/
COPY --from=builder /opt/acados/ /opt/acados/
# Set acados environment variables in runtime
ENV ACADOS_SOURCE_DIR=/opt/acados
ENV LD_LIBRARY_PATH=/opt/acados/lib:${LD_LIBRARY_PATH}
# Install tera renderer for acados template generation
ADD https://github.com/acados/tera_renderer/releases/download/v0.2.0/t_renderer-v0.2.0-linux-amd64 /opt/acados/bin/t_renderer
RUN chmod +x /opt/acados/bin/t_renderer
# Install nerfstudio CLI tab completions (may not exist in all nerfstudio versions)
RUN which ns-install-cli && ns-install-cli --mode install || true
WORKDIR /workspace
# Container startup script and info helper
RUN cat > /entrypoint.sh << 'ENTRYPOINT_EOF'
#!/bin/bash
exec "$@"
ENTRYPOINT_EOF
RUN chmod +x /entrypoint.sh
# Also add figs-info helper
RUN cat > /usr/local/bin/figs-info << 'INFO_EOF'
#!/bin/bash
echo "=== FiGS Environment Info ==="
python -c "import figs; print('figs: installed')" 2>/dev/null || echo "figs: not installed"
python -c "import gemsplat; print('gemsplat: installed')" 2>/dev/null || echo "gemsplat: not installed"
python -c "import gsplat; print('gsplat:', gsplat.__version__)" 2>/dev/null || echo "gsplat: not installed"
python -c "import numpy; print('numpy:', numpy.__version__)"
python -c "import torch; print('torch:', torch.__version__, '| CUDA:', torch.cuda.is_available())"
python -c "import acados_template; print('acados: installed')" 2>/dev/null || echo "acados: not installed"
which ns-train >/dev/null && echo "nerfstudio: installed" || echo "nerfstudio: not installed"
INFO_EOF
RUN chmod +x /usr/local/bin/figs-info
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/bin/bash", "-l"]