参考https://blog.csdn.net/Carry_all/article/details/103224043来进行的安装。途中遇到网络问题和make执行错误的问题。错误如下所示:
In file included from /root/wcf/ceres-solver/internal/ceres/compressed_row_sparse_matrix.h:43:0,
from /root/wcf/ceres-solver/internal/ceres/cuda_sparse_matrix.h:45,
from /root/wcf/ceres-solver/internal/ceres/cuda_sparse_matrix.cc:38:
/usr/include/glog/logging.h: In instantiation of ‘void google::MakeCheckOpValueString(std::ostream*, const T&) [with T = std::nullptr_t; std::ostream = std::basic_ostream<char>]’:
/usr/include/glog/logging.h:694:25: required from ‘std::__cxx11::string* google::MakeCheckOpString(const T1&, const T2&, const char*) [with T1 = ceres::internal::ContextImpl*; T2 = std::nullptr_t; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/usr/include/glog/logging.h:718:1: required from ‘std::__cxx11::string* google::Check_NEImpl(const T1&, const T2&, const char*) [with T1 = ceres::internal::ContextImpl*; T2 = std::nullptr_t; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/root/wcf/ceres-solver/internal/ceres/cuda_sparse_matrix.cc:69:3: required from here
/usr/include/glog/logging.h:638:9: error: ambiguous overload for ‘operator<<’ (operand types are ‘std::ostream {aka std::basic_ostream<char>}’ and ‘std::nullptr_t’)
(*os) << v;
~~~~~~^~~~
In file included from /usr/include/c++/7/istream:39:0,
from /usr/include/c++/7/sstream:38,
from /usr/include/c++/7/complex:45,
from /usr/include/eigen3/Eigen/Core:80,
from /root/wcf/ceres-solver/include/ceres/internal/eigen.h:34,
from /root/wcf/ceres-solver/internal/ceres/sparse_matrix.h:38,
from /root/wcf/ceres-solver/internal/ceres/compressed_row_sparse_matrix.h:41,
from /root/wcf/ceres-solver/internal/ceres/cuda_sparse_matrix.h:45,
from /root/wcf/ceres-solver/internal/ceres/cuda_sparse_matrix.cc:38:
/usr/include/c++/7/ostream:108:7: note: candidate: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
operator<<(__ostream_type& (*__pf)(__ostream_type&))
^~~~~~~~
/usr/include/c++/7/ostream:117:7: note: candidate: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ios_type& (*)(std::basic_ostream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>; std::basic_ostream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]
operator<<(__ios_type& (*__pf)(__ios_type&))
^~~~~~~~
/usr/include/c++/7/ostream:127:7: note: candidate: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
operator<<(ios_base& (*__pf) (ios_base&))
^~~~~~~~
/usr/include/c++/7/ostream:245:7: note: candidate: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
operator<<(const void* __p)
^~~~~~~~
In file included from /usr/include/c++/7/ostream:693:0,
from /usr/include/c++/7/istream:39,
from /usr/include/c++/7/sstream:38,
from /usr/include/c++/7/complex:45,
from /usr/include/eigen3/Eigen/Core:80,
from /root/wcf/ceres-solver/include/ceres/internal/eigen.h:34,
from /root/wcf/ceres-solver/internal/ceres/sparse_matrix.h:38,
from /root/wcf/ceres-solver/internal/ceres/compressed_row_sparse_matrix.h:41,
from /root/wcf/ceres-solver/internal/ceres/cuda_sparse_matrix.h:45,
from /root/wcf/ceres-solver/internal/ceres/cuda_sparse_matrix.cc:38:
/usr/include/c++/7/bits/ostream.tcc:119:5: note: candidate: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>]
basic_ostream<_CharT, _Traits>::
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/7/istream:39:0,
from /usr/include/c++/7/sstream:38,
from /usr/include/c++/7/complex:45,
from /usr/include/eigen3/Eigen/Core:80,
from /root/wcf/ceres-solver/include/ceres/internal/eigen.h:34,
from /root/wcf/ceres-solver/internal/ceres/sparse_matrix.h:38,
from /root/wcf/ceres-solver/internal/ceres/compressed_row_sparse_matrix.h:41,
from /root/wcf/ceres-solver/internal/ceres/cuda_sparse_matrix.h:45,
from /root/wcf/ceres-solver/internal/ceres/cuda_sparse_matrix.cc:38:
/usr/include/c++/7/ostream:574:5: note: candidate: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const unsigned char*) [with _Traits = std::char_traits<char>]
operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)
^~~~~~~~
/usr/include/c++/7/ostream:569:5: note: candidate: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const signed char*) [with _Traits = std::char_traits<char>]
operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)
^~~~~~~~
/usr/include/c++/7/ostream:556:5: note: candidate: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const char*) [with _Traits = std::char_traits<char>]
operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
^~~~~~~~
In file included from /usr/include/c++/7/ostream:693:0,
from /usr/include/c++/7/istream:39,
from /usr/include/c++/7/sstream:38,
from /usr/include/c++/7/complex:45,
from /usr/include/eigen3/Eigen/Core:80,
from /root/wcf/ceres-solver/include/ceres/internal/eigen.h:34,
from /root/wcf/ceres-solver/internal/ceres/sparse_matrix.h:38,
from /root/wcf/ceres-solver/internal/ceres/compressed_row_sparse_matrix.h:41,
from /root/wcf/ceres-solver/internal/ceres/cuda_sparse_matrix.h:45,
from /root/wcf/ceres-solver/internal/ceres/cuda_sparse_matrix.cc:38:
/usr/include/c++/7/bits/ostream.tcc:321:5: note: candidate: std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const char*) [with _CharT = char; _Traits = std::char_traits<char>]
operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)
^~~~~~~~
internal/ceres/CMakeFiles/ceres_internal.dir/build.make:1041: recipe for target 'internal/ceres/CMakeFiles/ceres_internal.dir/cuda_sparse_matrix.cc.o' failed
make[2]: *** [internal/ceres/CMakeFiles/ceres_internal.dir/cuda_sparse_matrix.cc.o] Error 1
CMakeFiles/Makefile2:154: recipe for target 'internal/ceres/CMakeFiles/ceres_internal.dir/all' failed
make[1]: *** [internal/ceres/CMakeFiles/ceres_internal.dir/all] Error 2
Makefile:145: recipe for target 'all' failed
通过搜索相关问题,发现是由于自己版本不对导致的(版本过旧和过新都有问题 我使用的是最新版本)。参照https://blog.csdn.net/weixin_43731435/article/details/117198844的方法,我将ceres-solver的版本库降低到1.14.0版本后,安装成功。使用的commit如下所示:
1.14.0
commit facb199f3eda902360f9e1d5271372b7e54febe1 [log] [tgz]
author Sameer Agarwal <sameeragarwal@google.com> Wed Mar 21 21:00:14 2018 -0700
committer Sameer Agarwal <sameeragarwal@google.com> Wed Mar 21 21:00:14 2018 -0700
tree ff8b99beacbd0ea25211d38f1b499202d68cb2b2
parent b5d6ee4a88694efb9dadd25c8cf4ae1b14407d7e [diff]
此后在安装colmap的时候也出现了问题,使用cmake编译报错。
先是出现下述错误
CMake Error at cmake/FindSQLite3.cmake:91 (message):
Could not find SQLite3
通过安装sqlite3以及dev套件解决
apt-get install libsqlite3
apt-get install libsqlite3-dev
然后是cmake编译问题
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found installed version of Eigen: /usr/lib/cmake/eigen3
-- Found required Ceres dependency: Eigen version 3.3.4 in /usr/include/eigen3
-- Found required Ceres dependency: glog
-- Found installed version of gflags: /usr/lib/x86_64-linux-gnu/cmake/gflags
-- Detected gflags version: 2.2.1
-- Found required Ceres dependency: gflags
-- Found Ceres version: 1.14.0 installed in: /usr/local with components: [EigenSparse, SparseLinearAlgebraLibrary, LAPACK, SuiteSparse, CXSparse, SchurSpecializations, OpenMP, Multithreading]
-- Found Boost: /usr/local/lib/cmake/Boost-1.80.0/BoostConfig.cmake (found version "1.80.0") found components: program_options filesystem graph system unit_test_framework
-- Found Eigen3: /usr/include/eigen3 (Required is at least version "2.91.0")
-- Found Eigen
-- Includes : /usr/include/eigen3
-- Found FreeImage
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libfreeimage.so
-- Found FLANN
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libflann.so
-- Found LZ4
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/liblz4.so
-- Found Glog
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libglog.so
-- Found SQLite3
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libsqlite3.so
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so
-- Found Glew
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libGLEW.so
-- Found Git: /usr/bin/git (found version "2.17.1")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- The CUDA compiler identification is NVIDIA 11.7.64
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc - skipped
-- Detecting CUDA compile features
-- Detecting CUDA compile features - done
-- Found Qt
-- Module : /root/anaconda3/lib/cmake/Qt5Core
-- Module : /root/anaconda3/lib/cmake/Qt5OpenGL
-- Module : /root/anaconda3/lib/cmake/Qt5Widgets
-- Found CGAL
-- Includes : /usr//include
-- Libraries : /usr/lib/x86_64-linux-gnu/libCGAL.so.13.0.1
-- Build type not specified, using Release
-- Enabling SIMD support
-- Enabling OpenMP support
-- Disabling interprocedural optimization
CMake Error at CMakeLists.txt:255 (message):
You must set CMAKE_CUDA_ARCHITECTURES to e.g. 'native', 'all-major', '70',
etc. More information at
https://cmake.org/cmake/help/latest/prop_tgt/CUDA_ARCHITECTURES.html
排查问题,大概意思是编译时未指定显卡,在CMakeList中加入如下代码
set(CMAKE_CUDA_ARCHITECTURES "native")
然后继续报错:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
METIS_INCLUDE_DIRS
used as include directory in directory /root/wcf/colmap
used as include directory in directory /root/wcf/colmap/lib
used as include directory in directory /root/wcf/colmap/lib/LSD
used as include directory in directory /root/wcf/colmap/lib/PBA
used as include directory in directory /root/wcf/colmap/lib/PoissonRecon
used as include directory in directory /root/wcf/colmap/lib/SiftGPU
used as include directory in directory /root/wcf/colmap/lib/VLFeat
used as include directory in directory /root/wcf/colmap/src
used as include directory in directory /root/wcf/colmap/src/base
used as include directory in directory /root/wcf/colmap/src/controllers
used as include directory in directory /root/wcf/colmap/src/estimators
used as include directory in directory /root/wcf/colmap/src/exe
根据错误,在网上寻找解决方案,得知可以使用Metis库来进行处理。在Ubuntu安装Metis库。
sudo apt-get install libmetis-dev
然后将对应的头文件位置以下述方式写入CMakeList.txt
set(METIS_INCLUDE_DIRS /usr/include/metis.h)
然后再次cmake,出现了一个新的问题。
-- Found installed version of Eigen: /usr/lib/cmake/eigen3
-- Found required Ceres dependency: Eigen version 3.3.4 in /usr/include/eigen3
-- Found required Ceres dependency: glog
-- Found installed version of gflags: /usr/lib/x86_64-linux-gnu/cmake/gflags
-- Detected gflags version: 2.2.1
-- Found required Ceres dependency: gflags
-- Found Ceres version: 1.14.0 installed in: /usr/local with components: [EigenSparse, SparseLinearAlgebraLibrary, LAPACK, SuiteSparse, CXSparse, SchurSpecializations, OpenMP, Multithreading]
-- Found Eigen
-- Includes : /usr/include/eigen3
-- Found FreeImage
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libfreeimage.so
-- Found FLANN
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libflann.so
-- Found LZ4
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/liblz4.so
-- Found Glog
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libglog.so
-- Found SQLite3
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libsqlite3.so
-- Found Glew
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libGLEW.so
-- Found Qt
-- Module : /root/anaconda3/lib/cmake/Qt5Core
-- Module : /root/anaconda3/lib/cmake/Qt5OpenGL
-- Module : /root/anaconda3/lib/cmake/Qt5Widgets
-- Found CGAL
-- Includes : /usr//include
-- Libraries : /usr/lib/x86_64-linux-gnu/libCGAL.so.13.0.1
-- Build type not specified, using Release
-- Enabling SIMD support
-- Enabling OpenMP support
-- Disabling interprocedural optimization
-- Enabling CUDA support (version: 11.7.64, archs: native)
-- Enabling GUI support
-- Enabling OpenGL support
-- Disabling ccache support
-- Disabling profiling support
-- Enabling CGAL support
-- Configuring done
CMake Warning at cmake/CMakeHelper.cmake:137 (add_executable):
Cannot generate a safe runtime search path for target colmap_exe because
files in some directories may conflict with libraries in implicit
directories:
runtime library [liblz4.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
/root/anaconda3/lib
runtime library [libtbbmalloc.so.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
/root/anaconda3/lib
runtime library [libtbb.so.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
/root/anaconda3/lib
runtime library [libsqlite3.so.0] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
/root/anaconda3/lib
runtime library [libgmp.so.10] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
/root/anaconda3/lib
Some of these libraries may not be found correctly.
Call Stack (most recent call first):
src/exe/CMakeLists.txt:38 (COLMAP_ADD_EXECUTABLE)
大概意思是在构建colmap_exe目标时,由于存在潜在的冲突,无法为它生成安全的运行时搜索路径。CMake发现/usr/lib/x86_64-linux-gnu目录中的某些库可能会被/root/anaconda3/lib目录中的库隐藏,这可能会导致colmap_exe找不到正确的库。解决方案很简单,将anaconda3改名,编译后再改回来即可。
如果jax版本不兼容会出现找不到GPU的情况。使用下述代码对jax重新安装
pip install --upgrade "jax[cuda]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
此后成功安装。
重新安装又遇到几个问题
-- The CUDA compiler identification is unknown
CMake Error at CMakeLists.txt:155 (enable_language):
No CMAKE_CUDA_COMPILER could be found.
Tell CMake where to find the compiler by setting either the environment
variable "CUDACXX" or the CMake cache entry CMAKE_CUDA_COMPILER to the full
path to the compiler, or to the compiler name if it is in the PATH.
是由于cmake未指定cuda导致。使用下列操作既可
cmake -D CMAKE_CUDA_COMPILER="/usr/local/cuda/bin/nvcc" CMmakeLists.txt ..
-- Disabling interprocedural optimization
CMake Error at CMakeLists.txt:255 (message):
You must set CMAKE_CUDA_ARCHITECTURES to e.g. 'native', 'all-major', '70',
etc. More information at
https://cmake.org/cmake/help/latest/prop_tgt/CUDA_ARCHITECTURES.html
CMAKEList.txt文件中没有设置指定的CUDA,在其中添加下列代码
set(CMAKE_CUDA_ARCHITECTURES 86) # rtx3090的值是86
使用make运行时报错文章来源:https://www.toymoban.com/news/detail-608051.html
-- Disabling interprocedural optimization
CMake Error at CMakeLists.txt:253 (message):
You must set CMAKE_CUDA_ARCHITECTURES to e.g. 'native', 'all-major', '70',
etc. More information at
https://cmake.org/cmake/help/latest/prop_tgt/CUDA_ARCHITECTURES.html
这是因为显卡算力与cuda版本不匹配导致的,参考https://blog.csdn.net/weixin_43678195/article/details/123574385添加环境变量既可解决此问题。文章来源地址https://www.toymoban.com/news/detail-608051.html
export TORCH_CUDA_ARCH_LIST="8.0"
到了这里,关于安装ceres-solver以及colmap遇到的坑的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!