Skip to content

Instantly share code, notes, and snippets.

@mihaidusmanu
Last active April 19, 2022 15:44
Show Gist options
  • Save mihaidusmanu/cab9d41972e68b137188c211c3af771e to your computer and use it in GitHub Desktop.
Save mihaidusmanu/cab9d41972e68b137188c211c3af771e to your computer and use it in GitHub Desktop.
COLMAP on Leonhard

Compiling COLMAP on Leonhard

This is a short tutorial for compiling COLMAP on Leonhard with GCC 6.3.0. Qt installation is quite large so COLMAP cannot be compiled in the home directories.

Modules and Paths

Create a file called colmap_startup.sh in your home directory containing the following:

export DATA=/cluster/project/infk/cvg/$USER

# COLMAP
module load gcc/6.3.0

module load cmake/3.4.3

module load boost eigen glog gflags glew

module load cgal openblas suite-sparse atlas

module load mpfr

module load mesa/12.0.3 mesa-glu

module load libxcb

module load cuda/10.0.130

export FREEIMAGE_DIR=/cluster/project/infk/cvg/$USER/dev/FreeImage/Dist
export Qt5_DIR=/cluster/project/infk/cvg/$USER/dev/qt5-build/qtbase/lib/cmake/Qt5

export COLMAP_PATH=/cluster/project/infk/cvg/$USER/dev/colmap/build/src/exe

Navigate to the project storage and create a folder for development:

source colmap_startup.sh
cd $DATA
mkdir dev
cd dev

Qt5

This part is adapted from the official tutorial.

git clone git://code.qt.io/qt/qt5.git
cd qt5
git checkout 5.9.8
perl init-repository --module-subset=qtbase
cd ..
mkdir qt5-build
cd qt5-build
../qt5/configure -developer-build -opensource -nomake examples -nomake tests
bsub -I -n 8 -R "rusage[mem=4096]" "make -j 8"
# Check that the compilation finished successfully.
cd ..

Ceres Solver

wget "http://ceres-solver.org/ceres-solver-1.14.0.tar.gz"
tar xvzf ceres-solver-1.14.0.tar.gz
rm ceres-solver-1.14.0.tar.gz
cd ceres-solver-1.14.0
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=Off -DEXPORT_BUILD_DIR=On ..
bsub -I -n 8 -R "rusage[mem=4096]" "make -j 8"
# Check that the compilation finished successfully.
bsub -I -n 8 -R "rusage[mem=4096]" "make test"
# Check that all tests pass.
cd ../..

FreeImage

wget "https://sourceforge.net/projects/freeimage/files/Source Distribution/3.18.0/FreeImage3180.zip"
unzip FreeImage3180.zip
rm FreeImage3180.zip
cd FreeImage
bsub -I -n 8 -R "rusage[mem=4096]" "make -j 8"
# Check that the compilation finished successfully.
cd ..

COLMAP

git clone https://github.com/colmap/colmap.git
cd colmap
mkdir build
cd build
cmake .. -DFREEIMAGE_INCLUDE_DIR_HINTS=$FREEIMAGE_DIR -DFREEIMAGE_LIBRARY_DIR_HINTS=$FREEIMAGE_DIR -DTESTS_ENABLED=ON -DCUDA_ARCHS="Pascal;Turing;Volta"
bsub -I -n 8 -R "rusage[mem=4096,ngpus_excl_p=1]" "make -j 8"
# Check that the compilation finished successfully.
bsub -I -n 8 -R "rusage[mem=4096,ngpus_excl_p=1]" "ctest"
# Check that tests pass. Currently known to fail: sift_test, opengl_utils_test.
cd ../..

Please note that currently there is no 30XX support on the cluster (no CUDA 11).

Comments

  • Known issue The matcher is currently not working - it seems to prefer OpenGL to CUDA even when OpenGL is disabled during compilation (-DOPENGL_ENABLED=OFF). I have tried multiple versions of CUDA and OpenGL, but the two tests mentioned above were always failing. I suggest using a custom matcher (i.e., PyTorch based) and running GV without GPU (--SiftMatching.use_gpu 0 option for matches_importer).
  • While I am around, you can probably use the compiled version of Qt / FreeImage available on my project storage. Try changing the following lines of colmap_startup.sh:
export FREEIMAGE_DIR=/cluster/project/infk/cvg/dusmanum/dev/FreeImage/Dist
export Qt5_DIR=/cluster/project/infk/cvg/dusmanum/dev/qt5-build/qtbase/lib/cmake/Qt5
@sebgiles
Copy link

sebgiles commented Apr 29, 2021

@oguzhanilter I am replying here instead of email so others can also see it.
After building COLMAP I also ran this to install it to an arbitrary location.

COLMAP_INSTALL_TARGET="/cluster/home/$USER/colmap"  # or what you prefer as long as you can r/w
mkdir $COLMAP_INSTALL_TARGET
bsub -I -n 8 -R "rusage[mem=4096,ngpus_excl_p=1]" "make DESTDIR=$COLMAP_INSTALL_TARGET install -j 8"

Then you will need to

export COLMAP_PATH=$COLMAP_INSTALL_TARGET/usr/local/bin/colmap
export COLMAP_DIR=$COLMAP_INSTALL_TARGET/usr/local/share/colmap

before building pycolmap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment