Skip to content

Optionally enable using GPU for Colmap for much faster processing.#38

Open
yanxke wants to merge 1 commit into
cre185:masterfrom
yanxke:yan/colmap-gpu
Open

Optionally enable using GPU for Colmap for much faster processing.#38
yanxke wants to merge 1 commit into
cre185:masterfrom
yanxke:yan/colmap-gpu

Conversation

@yanxke
Copy link
Copy Markdown
Contributor

@yanxke yanxke commented Jan 25, 2026

To enable GPU usage for colmap, must run a GUI'ed terminal and run once on login to enable permissions

xhost +local:docker

Then run

docker run --rm --gpus all --ipc=host \
  --ulimit memlock=-1 --ulimit stack=67108864 \
  -e DISPLAY=$DISPLAY \
  -e NVIDIA_DRIVER_CAPABILITIES=graphics,compute,utility \
  -e QT_QPA_PLATFORM=xcb \
  -e QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms \
  -e QT_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/qt5/plugins \
  -e XDG_RUNTIME_DIR=/tmp/runtime-docker \
  -e INSTANTSFM_COLMAP_USE_GPU=1 \
  -v /tmp/.X11-unix:/tmp/.X11-unix \
  -v "$PWD":/workspace/InstantSfM \
  -w /workspace/InstantSfM \
  instantsfm \
  bash -lc '
    set -e
    mkdir -p /tmp/runtime-docker && chmod 700 /tmp/runtime-docker

    if [ -d /usr/local/lib/python3.12/dist-packages/cv2/qt/plugins ]; then
      mv /usr/local/lib/python3.12/dist-packages/cv2/qt \
         /usr/local/lib/python3.12/dist-packages/cv2/qt.disabled
    fi

    ins-feat --data_path examples/kitchen --feature_handler colmap --manual_config_name colmap
    ins-sfm  --data_path examples/kitchen --manual_config_name colmap --export_txt
  '

@yanxke yanxke changed the title Optionally enable using GPU for Colmap for much faster processing. DRAFT: Optionally enable using GPU for Colmap for much faster processing. Jan 25, 2026
@yanxke yanxke changed the title DRAFT: Optionally enable using GPU for Colmap for much faster processing. Optionally enable using GPU for Colmap for much faster processing. Jan 25, 2026
@cre185
Copy link
Copy Markdown
Owner

cre185 commented Jan 26, 2026

@zitongzhan is disabling gpu support in colmap the desired behavior? It's reasonable to add gpu support if available. Also, would it be possible to simply add a parameter in the feat.py script and pass it to feature handler, so that extra effort to set environment variable is not required?

@zitongzhan
Copy link
Copy Markdown
Collaborator

@zitongzhan is disabling gpu support in colmap the desired behavior? It's reasonable to add gpu support if available. Also, would it be possible to simply add a parameter in the feat.py script and pass it to feature handler, so that extra effort to set environment variable is not required?

@yanxke was right that colmap relies on GUI to make CUDA acceleration possible. colmap would crash if user attempts to use CUDA on a headless system.
I am thinking of a simpler way to achieve this: instead of adding a new env variable, we could check if the DISPLAY env variable is there or not to see availability of headful GUI

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants