File size: 2,665 Bytes
7a87926
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Base image with heavy dependencies (COLMAP, hloc, LightGlue)
# This image is built separately and cached to save 20-25 minutes per build
# Using devel image instead of runtime to include CUDA development tools (nvcc) needed for gsplat
FROM pytorch/pytorch:2.1.0-cuda11.8-cudnn8-devel

# Set working directory
WORKDIR /app

# Set timezone and non-interactive mode to avoid prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# Install system dependencies for COLMAP
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
    build-essential \
    cmake \
    git \
    libeigen3-dev \
    libfreeimage-dev \
    libmetis-dev \
    libgoogle-glog-dev \
    libgflags-dev \
    libglew-dev \
    libsuitesparse-dev \
    libboost-all-dev \
    libatlas-base-dev \
    libblas-dev \
    liblapack-dev \
    && rm -rf /var/lib/apt/lists/*

# Install COLMAP (this takes ~15-20 minutes)
# COLMAP will automatically download and build Ceres Solver as a dependency
RUN git clone --recursive https://github.com/colmap/colmap.git /tmp/colmap && \
    cd /tmp/colmap && \
    git checkout 3.8 && \
    git submodule update --init --recursive && \
    mkdir build && \
    cd build && \
    cmake .. \
        -DCMAKE_BUILD_TYPE=Release \
        -DCERES_SOLVER_AUTO=ON && \
    make -j$(nproc) && \
    make install && \
    cd / && \
    rm -rf /tmp/colmap && \
    # Verify COLMAP installation
    colmap -h || echo "COLMAP installed"

# Install Python dependencies that don't change often
# Note: Pin PyTorch to 2.1.0 to match CUDA 11.8 in base image (avoid version mismatch with gsplat)
RUN pip install --no-cache-dir \
    "torch==2.1.0" \
    "torchvision==0.16.0" \
    "numpy<2.0" \
    opencv-python \
    pillow \
    tqdm \
    huggingface-hub \
    safetensors \
    einops \
    omegaconf \
    "pycolmap>=0.4.0" \
    "typer[all]>=0.9.0" \
    "matplotlib>=3.5.0" \
    "plotly>=5.0.0" \
    imageio \
    xformers \
    open3d \
    tensorboard

# Install LightGlue (from git)
RUN pip install --no-cache-dir git+https://github.com/cvg/LightGlue.git

# Install hloc (Hierarchical Localization)
RUN git clone https://github.com/cvg/Hierarchical-Localization.git /tmp/hloc && \
    cd /tmp/hloc && \
    pip install --no-cache-dir -e . && \
    cd / && \
    rm -rf /tmp/hloc

# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app

# Label for identification
LABEL org.opencontainers.image.title="YLFF Base Image"
LABEL org.opencontainers.image.description="Base image with COLMAP, hloc, and LightGlue pre-installed"