File size: 4,419 Bytes
08d80be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cb2de0f
 
08d80be
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# --- `colmap` Builder Stage ---
FROM nvidia/cuda:11.7.1-devel-ubuntu20.04 AS colmap_builder

ARG COLMAP_GIT_COMMIT=main
ARG CUDA_ARCHITECTURES=native
ENV QT_XCB_GL_INTEGRATION=xcb_egl

WORKDIR /workdir

# Prepare and empty machine for building.
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
    git \
    cmake \
    ninja-build \
    build-essential \
    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 \
    && rm -rf /var/lib/apt/lists/*

# Build and install COLMAP.
COPY deps/colmap /colmap
RUN cd /colmap && \
    mkdir build && \
    cd build && \
    cmake .. -GNinja -DCMAKE_CUDA_ARCHITECTURES=${CUDA_ARCHITECTURES} && \
    ninja && \
    ninja install && \
    cd .. && rm -rf colmap

# # --- `gaussian-splatting-cuda` Builder Stage ---
FROM nvidia/cuda:11.7.1-devel-ubuntu20.04 AS gs_builder

WORKDIR /workdir

# Install dependencies
# we could pin them to specific versions to be extra sure
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
    git \
    python3-dev \
    libtbb-dev \
    libeigen3-dev \
    unzip \
    g++ \
    libssl-dev \
    build-essential \
    checkinstall \
    wget \
    cmake \
    protobuf-compiler \
 && rm -rf /var/lib/apt/lists/*

# Install cmake 3.25
# RUN apt-get update && apt-get -y install 
RUN wget https://github.com/Kitware/CMake/releases/download/v3.25.0/cmake-3.25.0.tar.gz \
 && tar -zvxf cmake-3.25.0.tar.gz \
 && cd cmake-3.25.0 \
 && ./bootstrap \
 && make -j8 \
 && checkinstall --pkgname=cmake --pkgversion="3.25-custom" --default

# Copy necessary files
COPY deps/gaussian-splatting-cuda/cuda_rasterizer ./cuda_rasterizer
COPY deps/gaussian-splatting-cuda/external ./external
COPY deps/gaussian-splatting-cuda/includes ./includes
COPY deps/gaussian-splatting-cuda/parameter ./parameter
COPY deps/gaussian-splatting-cuda/src ./src
COPY deps/gaussian-splatting-cuda/CMakeLists.txt ./CMakeLists.txt

# Download and extract libtorch
RUN wget https://download.pytorch.org/libtorch/cu118/libtorch-cxx11-abi-shared-with-deps-2.0.1%2Bcu118.zip \
 && unzip -o libtorch-cxx11-abi-shared-with-deps-2.0.1+cu118.zip -d external/ \
 && rm libtorch-cxx11-abi-shared-with-deps-2.0.1+cu118.zip

# Build (on CPU, this will add compute_35 as build target, which we do not want)
ENV PATH /usr/local/cuda/bin:$PATH
ENV LD_LIBRARY_PATH /usr/local/cuda/lib64:$LD_LIBRARY_PATH
RUN cmake -B build -D CMAKE_BUILD_TYPE=Release -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda/ -D CUDA_VERSION=11.7 \
 && cmake --build build -- -j8

# --- Runner Stage ---
FROM nvidia/cuda:11.7.1-devel-ubuntu20.04 AS runner

WORKDIR /app

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
    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 \
    imagemagick \
    ffmpeg \
    python3-pip \
    && rm -rf /var/lib/apt/lists/*

# Copy built artifact from colmap_builder stage
COPY --from=colmap_builder /usr/local/bin/colmap /usr/local/bin/colmap

# Copy built artifact from builder stage
COPY --from=gs_builder /workdir/build/gaussian_splatting_cuda /usr/local/bin/gaussian_splatting_cuda
COPY --from=gs_builder /workdir/external/libtorch /usr/local/libtorch
COPY --from=gs_builder /workdir/parameter /usr/local/bin/parameter

# Setup environment
ENV PATH /usr/local/libtorch/bin:/usr/local/cuda/bin:$PATH
ENV LD_LIBRARY_PATH /usr/local/libtorch/lib:/usr/local/cuda/lib64:$LD_LIBRARY_PATH
ENV LC_ALL C
ENV LANG C

# Install python dependencies
COPY requirements.txt /app/requirements.txt
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install -r /app/requirements.txt

COPY services /app/services
COPY server.py /app/server.py

# Fix bug
RUN mkdir /parameter && cp /usr/local/bin/parameter/optimization_params.json /parameter/optimization_params.json

EXPOSE 7860
CMD [ "python3", "-u", "/app/server.py" ]