Skip to content

Instantly share code, notes, and snippets.

@ochafik
Last active February 2, 2022 03:57
Show Gist options
  • Select an option

  • Save ochafik/0ac3d598f3cb07f738df7f96ef670ac7 to your computer and use it in GitHub Desktop.

Select an option

Save ochafik/0ac3d598f3cb07f738df7f96ef670ac7 to your computer and use it in GitHub Desktop.
colmap + CUDA on a remote VM w/ GPU

[TOC]

Intro

https://vast.ai/console/create/

  • Images?
    • tensorflow/tensorflow:latest-gpu (commands below) --> w/ Jupyter
    • 11.2.2-devel-ubuntu20.04 --> w/ SSH

Build colmap

As root on 18.04.1-Ubuntu (Docker tensorflow/tensorflow:latest-gpu):

apt-get update && \
apt-get install -y \
    git \
    cmake \
    htop \
    build-essential \
    libboost-program-options-dev \
    libboost-filesystem-dev \
    libboost-graph-dev \
    libboost-system-dev \
    libboost-test-dev \
    libeigen3-dev \
    libsuitesparse-dev \
    libfreeimage-dev \
    libgoogle-glog-dev \
    libgflags-dev \
    libglew-dev \
    libglu1-mesa-dev \
    mesa-common-dev \
    libatlas-base-dev \
    libsuitesparse-dev \
    qtbase5-dev \
    libqt5opengl5-dev \
    libcgal-dev

# nvcc --version # 11.2, so:
# apt-get install -y cuda-libraries-dev-11-2 # Includes libcurand-dev

( git clone https://ceres-solver.googlesource.com/ceres-solver && \
cd ceres-solver && \
git checkout $(git describe --tags)  && \
mkdir build && \
cd build && \
cmake .. -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF && \
make -j && \
make install )

( git clone https://github.com/colmap/colmap.git && \
cd colmap && \
git checkout dev && \
mkdir -p build && \
cd build && \
cmake .. \
  -DCMAKE_PREFIX_PATH=/usr/local \
  -DOPENGL_ENABLED=0 \
  -DGUI_ENABLED=0 && \
  -DTESTS_ENABLED=0 && \
  -DCMAKE_CXX_FLAGS="-DGL_LUMINANCE=0x1909 -DGL_UNSIGNED_BYTE=0x1401" && \
make -j$(( $(nproc --all) - 1 )) && \
make install )

( cd ceres-solver/build ; tar -czvf ../../ceres-solver_build.tar.gz . )
( cd colmap/build ; tar -czvf ../../colmap_build.tar.gz . )
# Now these can be downloaded from Jupyter for future use

Reuse prebuilt colmap

mkdir -p colmap ceres-solver
tar -xzvf colmap_build.tar.gz -C colmap/build
tar -xzvf ceres-solver_build.tar.gz -C ceres-solver/build
unzip Pictures.zip
mkdir Recon

# If multiple GPUs, add --PatchMatchStereo.gpu_index=0,0,1,1 for instance (2 threads per GPU)
#   (see https://colmap.github.io/faq.html#multi-gpu-support-in-dense-reconstruction)
# General speedup instructions: https://colmap.github.io/faq.html#speedup-dense-reconstruction
time /usr/local/bin/colmap automatic_reconstructor \
  --image_path Pictures \
  --workspace_path Recon

tar -czvf Recon.tar.gz Recon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment