|
| 1 | +FROM nvcr.io/nvidia/pytorch:25.11-py3 |
| 2 | + |
| 3 | +ARG TARGETARCH |
| 4 | +ARG DEBIAN_FRONTEND=noninteractive |
| 5 | + |
| 6 | +# Core build tooling and runtime libs needed by scikit-sparse / OpenCV / fused-ssim |
| 7 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 8 | + build-essential cmake ninja-build git wget ca-certificates xz-utils \ |
| 9 | + libgoogle-glog-dev libgflags-dev libatlas-base-dev libeigen3-dev \ |
| 10 | + libsuitesparse-dev libmetis-dev liblapack-dev libblas-dev \ |
| 11 | + libgl1 libglib2.0-0 colmap \ |
| 12 | + && rm -rf /var/lib/apt/lists/* |
| 13 | + |
| 14 | +# Install cuDSS for CUDA 13 (arch-aware) |
| 15 | +ARG CUDSS_VERSION=0.7.1.4 |
| 16 | +ENV CUDSS_ROOT=/opt/cudss-${CUDSS_VERSION} |
| 17 | +RUN set -euo pipefail; \ |
| 18 | + arch="${TARGETARCH:-$(uname -m)}"; \ |
| 19 | + case "${arch}" in \ |
| 20 | + amd64|x86_64) cudss_arch="x86_64"; deb_arch_dir="x86_64-linux-gnu";; \ |
| 21 | + arm64|aarch64) cudss_arch="aarch64"; deb_arch_dir="aarch64-linux-gnu";; \ |
| 22 | + *) echo "Unsupported architecture: ${arch}"; exit 1;; \ |
| 23 | + esac; \ |
| 24 | + CUDSS_TARBALL="libcudss-linux-${cudss_arch}-${CUDSS_VERSION}_cuda13-archive.tar.xz"; \ |
| 25 | + CUDSS_URL_BASE="https://developer.download.nvidia.com/compute/cudss/redist/libcudss/linux-${cudss_arch}"; \ |
| 26 | + wget -q "${CUDSS_URL_BASE}/${CUDSS_TARBALL}" -O /tmp/cudss.tar.xz; \ |
| 27 | + tar -xJf /tmp/cudss.tar.xz -C /opt; \ |
| 28 | + ln -s "/opt/libcudss-linux-${cudss_arch}-${CUDSS_VERSION}_cuda13-archive" "${CUDSS_ROOT}"; \ |
| 29 | + mkdir -p /usr/include/libcudss/12 "/usr/lib/${deb_arch_dir}/libcudss/12"; \ |
| 30 | + cp -r "${CUDSS_ROOT}/include/"* /usr/include/libcudss/12/; \ |
| 31 | + cp -r "${CUDSS_ROOT}/lib/"* "/usr/lib/${deb_arch_dir}/libcudss/12/"; \ |
| 32 | + ldconfig; \ |
| 33 | + rm /tmp/cudss.tar.xz |
| 34 | + |
| 35 | +# cuDSS toolchain paths |
| 36 | +ENV CUDSS_LIBCUDSS_PATHS=/usr/lib/aarch64-linux-gnu/libcudss/12:/usr/lib/x86_64-linux-gnu/libcudss/12 |
| 37 | +ENV LD_LIBRARY_PATH=${CUDSS_ROOT}/lib:${CUDSS_LIBCUDSS_PATHS}:${LD_LIBRARY_PATH} |
| 38 | +ENV LIBRARY_PATH=${CUDSS_ROOT}/lib:${CUDSS_LIBCUDSS_PATHS}:${LIBRARY_PATH} |
| 39 | +ENV CPATH=${CUDSS_ROOT}/include |
| 40 | +ENV CUDA_HOME=/usr/local/cuda |
| 41 | +ENV FUSED_SSIM_FORCE_CUDA=1 |
| 42 | +ENV TORCH_CUDA_ARCH_LIST="8.0;9.0;8.6;8.9;11.0" |
| 43 | + |
| 44 | +# Build and install Ceres Solver (needed by pyceres) |
| 45 | +ARG CERES_VERSION=2.1.0 |
| 46 | +RUN wget -q http://ceres-solver.org/ceres-solver-${CERES_VERSION}.tar.gz \ |
| 47 | + && tar zxf ceres-solver-${CERES_VERSION}.tar.gz \ |
| 48 | + && mkdir ceres-build \ |
| 49 | + && cd ceres-build \ |
| 50 | + && cmake ../ceres-solver-${CERES_VERSION} -GNinja \ |
| 51 | + -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DBUILD_SHARED_LIBS=ON \ |
| 52 | + -DMINIGLOG=OFF -DSUITESPARSE=OFF -DCXSPARSE=OFF \ |
| 53 | + && ninja install \ |
| 54 | + && cd / \ |
| 55 | + && rm -rf ceres-build ceres-solver-${CERES_VERSION} ceres-solver-${CERES_VERSION}.tar.gz |
| 56 | + |
| 57 | +WORKDIR /workspace/InstantSfM |
| 58 | + |
| 59 | +# Install Python dependencies (including external git deps) first for better layer caching |
| 60 | +COPY pyproject.toml README.md ./ |
| 61 | +COPY instantsfm instantsfm |
| 62 | +COPY demo.py demo.py |
| 63 | +RUN pip install --no-cache-dir numpy==1.26.4 \ |
| 64 | + && git clone --depth=1 https://github.com/rahul-goel/fused-ssim /tmp/fused-ssim \ |
| 65 | + && python -c "from pathlib import Path; p=Path('/tmp/fused-ssim/setup.py'); t=p.read_text(); t=t.replace('elif torch.mps.is_available():','elif False and torch.mps.is_available():'); t=t.replace('elif hasattr(torch, \\'xpu\\'):', 'elif False and hasattr(torch, \\'xpu\\'):'); p.write_text(t)" \ |
| 66 | + && pip install --no-cache-dir --no-build-isolation /tmp/fused-ssim \ |
| 67 | + && pip install --no-cache-dir --upgrade pip \ |
| 68 | + && MAX_JOBS=$(nproc) pip install --no-cache-dir --no-build-isolation git+https://github.com/zitongzhan/bae.git \ |
| 69 | + && pip install --no-cache-dir . |
| 70 | + |
| 71 | +# Bring in the rest of the project (assets, configs, etc.) |
| 72 | +COPY . . |
| 73 | + |
| 74 | +CMD ["/bin/bash"] |
0 commit comments