8000 added gpu support by min-hieu-netropy · Pull Request #174 · colmap/glomap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

added gpu support #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Mar 20, 2025
Merged

added gpu support #174

merged 18 commits into from
Mar 20, 2025

Conversation

min-hieu-netropy
Copy link
Contributor
@min-hieu-netropy min-hieu-netropy commented Mar 10, 2025

added gpu support to global positioning and bundle adjustment
stats on a 1k image data set with exhaustive matching on RTX4090:

  • global positioning:
    • cpu: 420.37341s
    • gpu: 94.93816s
  • bundle adjustment:
    • cpu: 72.99911s (first stage), 1074.74076s (second stage)
    • gpu: 114.81785s (first stage), 343.74347s (second stage)

I think the performance gain would be much higher on bigger dataset since the gpu utilization is only ~20% when I run these tests. Also, global positioning seems to benefit the most from GPU usage

@ichsan2895
Copy link

Sorry, I am not good for advance coding, but I really appreciate this PR. Please @lpanaf consider to merge it when it ready.

CMakeLists.txt Outdated
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.28)

project(glomap VERSION 1.0.0)
project(glomap_gpu VERSION 1.0.0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the original project name.

We should add an option to enable/disable CUDA support (similar to how colmap works).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I was fixed the naming back to glomap. The commit has the GlobalPositioning.use_gpu and BundleAdjustment.use_gpu options in option_manager.cc

@lpanaf
Copy link
Collaborator
lpanaf commented Mar 13, 2025

Hi @min-hieu-netropy, thank you very much for this pull request. I was checking your code and figured that the min_num_images_gpu_solver for the global positioning step and the bundle adjustment step are set to be 1000, 300. Did you run any experiments to choose this number? If not, I would prefer to keep it consistent with the heuristic number set by COLMAP (50 in this case)

@min-hieu-netropy
Copy link
Contributor Author

Hi @min-hieu-netropy, thank you very much for this pull request. I was checking your code and figured that the min_num_images_gpu_solver for the global positioning step and the bundle adjustment step are set to be 1000, 300. Did you run any experiments to choose this number? If not, I would prefer to keep it consistent with the heuristic number set by COLMAP (50 in this case)

Hi, I originally put in the colmap number but wanted to experiment with different datasets so I made it 1000 and 300. However feel free to change it.

@DuVogel87
Copy link

i added:

'--GlobalPositioning.use_gpu 1
--BundleAdjustment.use_gpu 1 '

to my script.

But when running it i get this error:

'I20250318 20:11:45.942935 31020 image_undistorter.cc:20] Undistorting images..
I20250318 20:11:45.942958 31020 image_undistorter.cc:41] Image undistortion done
I20250318 20:11:45.943114 31020 global_positioning.cc:46] Setting up the global positioner problem
W20250318 20:11:54.332746 31020 global_positioning.cc:380] Requested to use GPU for bundle adjustment, but Ceres was compiled without CUDA support. Falling back to CPU-based dense solvers.
W20250318 20:11:54.333981 31020 global_positioning.cc:397] Requested to use GPU for bundle adjustment, but Ceres was compiled without cuDSS support. Falling back to CPU-based sparse solvers.
I20250318 20:11:54.333993 31020 global_positioning.cc:71] Solving the global positioner problem
I20250318 20:26:16.512383 31020 global_positioning.cc:80] Ceres Solver Report: Iterations: 60, Initial cost: 2.755906e+07, Final cost: 5.299410e+01, Termination: CONVERGENCE
I20250318 20:26:16.936136 31020 track_filter.cc:86] Filtered 1422 / 635890 tracks by angle error
I20250318 20:26:16.945920 31020 timer.cc:87] Elapsed time: 871.00336 [seconds]'

I get this when running 'colmap -h'
'COLMAP 3.12.0.dev0 -- Structure-from-Motion and Multi-View Stereo
(Commit 6556b4e2 on 2025-03-04 with CUDA)'

This when running 'glomap -h'
'GLOMAP -- Global Structure-from-Motion
This version was compiled with CUDA!'

Don't know what i did wrong. I appreciate any form of help. Thx!

@min-hieu-netropy
Copy link
Contributor Author

Hi, it seems like you're using a ceres version without CUDA support. You can try building ceres (version >= 2.3) from source and try again.

@lpanaf lpanaf merged commit ce51d8b into colmap:main Mar 20, 2025
8 checks passed
@xiemeilong
Copy link
xiemeilong commented Mar 22, 2025

How much VRAM do I approximately need? I was able to run it successfully with 3600 images, but I get an error when I use 6000 or 9000. Is this because I don't have enough VRAM? My VRAM is 16GB.

-------------------------------------
I20250321 10:49:13.659646  4070 image_undistorter.cc:20] Undistorting images..
I20250321 10:49:13.659672  4070 image_undistorter.cc:41] Image undistortion done
I20250321 10:49:13.660104  4070 global_positioning.cc:46] Setting up the global positioner problem
I20250321 10:49:36.217622  4070 global_positioning.cc:71] Solving the global positioner problem
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
F0000 00:00:1742554194.110962    4070 block_sparse_matrix.cc:818] Check failed: cudaSuccess == cudaHostAlloc(&values, sizeof(double) * size, cudaHostAllocDefault) (0 vs. 1) 
*** Check failure stack trace: ***
    @     0x5f72ed1d4c7d  absl::lts_20240722::log_internal::LogMessage::PrepareToDie()
    @     0x5f72ed1d4cf5  absl::lts_20240722::log_internal::LogMessage::SendToLog()
    @     0x5f72ed1d4711  absl::lts_20240722::log_internal::LogMessage::Flush()
    @     0x5f72ed1d5026  absl::lts_20240722::log_internal::LogMessageFatal::~LogMessageFatal()
    @     0x5f72ec72b77d  ceres::internal::BlockSparseMatrix::AllocateValues()
*** Aborted at 1742554194 (unix time) try "date -d @1742554194" if you are using GNU date ***
PC: @                0x0 (unknown)
*** SIGABRT (@0xfe6) received by PID 4070 (TID 0x7572e836c000) from PID 4070; stack trace: ***
    @     0x757330e6b206 (unknown)
    @     0x75730c506330 (unknown)
    @     0x75730c55fb2c pthread_kill
    @     0x75730c50627e gsignal
    @     0x75730c4e98ff abort
    @     0x5f72ed1d4261 absl::lts_20240722::log_internal::LogMessage::FailWithoutStackTrace()
    @     0x5f72ed1d4cc4 absl::lts_20240722::log_internal::LogMessage::Die()
    @     0x5f72ed1d4d78 absl::lts_20240722::log_internal::LogMessage::SendToLog()
    @     0x5f72ed1d4711 absl::lts_20240722::log_internal::LogMessage::Flush()
    @     0x5f72ed1d5026 absl::lts_20240722::log_internal::LogMessageFatal::~LogMessageFatal()
    @     0x5f72ec72b77d _ZN5ceres8internal17BlockSparseMatrix14AllocateValuesEi.cold
    @     0x5f72ecd4b080 ceres::internal::BlockSparseMatrix::BlockSparseMatrix()
    @     0x5f72ecd90e4a ceres::internal::BlockJacobianWriter::CreateJacobian()
    @     0x5f72ecd5d435 ceres::internal::ProgramEvaluator<>::CreateJacobian()
    @     0x5f72ecd8425c ceres::internal::TrustRegionPreprocessor::Preprocess()
    @     0x5f72ecd3e0e6 ceres::Solver::Solve()
    @     0x5f72ecd3fa2b ceres::Solve()
    @     0x5f72ec7b73f7 glomap::GlobalPositioner::Solve()
    @     0x5f72ec75a821 glomap::GlobalMapper::Solve()
    @     0x5f72ec751af8 glomap::RunMapper()
    @     0x5f72ec74c043 main
    @     0x75730c4eb1ca (unknown)
    @     0x75730c4eb28b __libc_start_main
    @     0x5f72ec74d0a5 _start
Aborted (core dumped)
ERROR:root:Mapper failed with code 34304. Exiting.

Sat Mar 22 03:20:47 2025       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 565.57.01              Driver Version: 565.57.01      CUDA Version: 12.7     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 4080 ...    On  |   00000000:01:00.0  On |                  N/A |
|  0%   30C    P8              2W /  320W |     506MiB /  16376MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
+-----------------------------------------------------------------------------------------+

@xiemeilong
Copy link

This exception might also happen even with just 1000 photos.

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.

6 participants
0