You are not logged in.

#1 2025-05-28 22:55:46

DrChelomey
Member
Registered: 2025-05-28
Posts: 2

Issues with CUDA and GCC

Hello all,
I have spent the better part of an afternoon on this and still cannot get this to work.
When building any app which has CUDA as a dependency, this happens:

CMake Error at /usr/share/cmake/Modules/CMakeDetermineCompilerId.cmake:909 (message):
  Compiling the CUDA compiler identification source file
  "CMakeCUDACompilerId.cu" failed.

  Compiler: /opt/cuda/bin/nvcc

  Build flags:

  Id flags: --keep;--keep-dir;tmp;-ccbin=/usr/bin/gcc -v



  The output was:

  2

  nvcc warning : Support for offline compilation for architectures prior to
  '<compute/sm/lto>_75' will be removed in a future release (Use
  -Wno-deprecated-gpu-targets to suppress warning).

  #$ _NVVM_BRANCH_=nvvm

  #$ _SPACE_=

  #$ _CUDART_=cudart

  #$ _HERE_=/opt/cuda/bin

  #$ _THERE_=/opt/cuda/bin

  #$ _TARGET_SIZE_=

  #$ _TARGET_DIR_=

  #$ _TARGET_DIR_=targets/x86_64-linux

  #$ TOP=/opt/cuda/bin/..

  #$ CICC_PATH=/opt/cuda/bin/../nvvm/bin

  #$ NVVMIR_LIBRARY_DIR=/opt/cuda/bin/../nvvm/libdevice

  #$ LD_LIBRARY_PATH=/opt/cuda/bin/../lib:/opt/cuda/lib64:

  #$
  PATH=/opt/cuda/bin/../nvvm/bin:/opt/cuda/bin:/home/escape/.local/cuda-gcc:/opt/cuda/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/opt/cuda/bin:/opt/cuda/nsight_compute:/opt/cuda/nsight_systems/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

  #$ INCLUDES="-I/opt/cuda/bin/../targets/x86_64-linux/include"

  #$ LIBRARIES= "-L/opt/cuda/bin/../targets/x86_64-linux/lib/stubs"
  "-L/opt/cuda/bin/../targets/x86_64-linux/lib"

  #$ CUDAFE_FLAGS=

  #$ PTXAS_FLAGS=

  #$ rm tmp/a_dlink.reg.c

  #$ "/usr/bin"/gcc -D__CUDA_ARCH_LIST__=520 -D__NV_LEGACY_LAUNCH -E -x c++
  -D__CUDACC__ -D__NVCC__ "-I/opt/cuda/bin/../targets/x86_64-linux/include"
  -D__CUDACC_VER_MAJOR__=12 -D__CUDACC_VER_MINOR__=8
  -D__CUDACC_VER_BUILD__=93 -D__CUDA_API_VER_MAJOR__=12
  -D__CUDA_API_VER_MINOR__=8 -D__NVCC_DIAG_PRAGMA_SUPPORT__=1
  -D__CUDACC_DEVICE_ATOMIC_BUILTINS__=1 -include "cuda_runtime.h" -m64
  "CMakeCUDACompilerId.cu" -o "tmp/CMakeCUDACompilerId.cpp4.ii"

  #$ cudafe++ --c++17 --gnu_version=150101 --display_error_number
  --orig_src_file_name "CMakeCUDACompilerId.cu" --orig_src_path_name
  "/home/escape/.cache/paru/clone/colmap/src/build/CMakeFiles/4.0.2-dirty/CompilerIdCUDA/CMakeCUDACompilerId.cu"
  --allow_managed --m64 --parse_templates --gen_c_file_name
  "tmp/CMakeCUDACompilerId.cudafe1.cpp" --stub_file_name
  "CMakeCUDACompilerId.cudafe1.stub.c" --gen_module_id_file
  --module_id_file_name "tmp/CMakeCUDACompilerId.module_id"
  "tmp/CMakeCUDACompilerId.cpp4.ii"

  /usr/include/c++/15.1.1/type_traits(554): error: type name is not allowed

        : public __bool_constant<__is_pointer(_Tp)>
                                              ^



  /usr/include/c++/15.1.1/type_traits(554): error: identifier "__is_pointer"
  is undefined

        : public __bool_constant<__is_pointer(_Tp)>
                                 ^



  /usr/include/c++/15.1.1/type_traits(876): error: type name is not allowed

        : public __bool_constant<__is_volatile(_Tp)>
                                               ^



  /usr/include/c++/15.1.1/type_traits(876): error: identifier "__is_volatile"
  is undefined

        : public __bool_constant<__is_volatile(_Tp)>
                                 ^



  /usr/include/c++/15.1.1/type_traits(1491): error: type name is not allowed

        : public integral_constant<std::size_t, __array_rank(_Tp)> { };
                                                             ^



  /usr/include/c++/15.1.1/type_traits(1491): error: identifier "__array_rank"
  is undefined

        : public integral_constant<std::size_t, __array_rank(_Tp)> { };
                                                ^



  /usr/include/c++/15.1.1/type_traits(1843): error: incomplete type
  "std::__cv_selector<std::__make_unsigned_selector<wchar_t, false,
  true>::__unsigned_type, false, <error-constant>>" (aka
  "std::__cv_selector<unsigned int, false, <error-constant>>") is not allowed

          using __type = typename __match::__type;
                                  ^
            detected during:
              instantiation of class "std::__match_cv_qualifiers<_Qualified, _Unqualified, _IsConst, _IsVol> [with _Qualified=wchar_t, _Unqualified=unsigned int, _IsConst=false, _IsVol=<error-constant>]" at line 1952
              instantiation of class "std::__make_unsigned_selector<_Tp, false, true> [with _Tp=wchar_t]" at line 1963



  /usr/include/c++/15.1.1/type_traits(1843): error: incomplete type
  "std::__cv_selector<std::__make_unsigned_selector<char16_t, false,
  true>::__unsigned_type, false, <error-constant>>" (aka
  "std::__cv_selector<unsigned short, false, <error-constant>>") is not
  allowed

          using __type = typename __match::__type;
                                  ^
            detected during:
              instantiation of class "std::__match_cv_qualifiers<_Qualified, _Unqualified, _IsConst, _IsVol> [with _Qualified=char16_t, _Unqualified=unsigned short, _IsConst=false, _IsVol=<error-constant>]" at line 1952
              instantiation of class "std::__make_unsigned_selector<_Tp, false, true> [with _Tp=char16_t]" at line 1979



  /usr/include/c++/15.1.1/type_traits(1843): error: incomplete type
  "std::__cv_selector<std::__make_unsigned_selector<wchar_t, false,
  true>::__unsigned_type, false, <error-constant>>" (aka
  "std::__cv_selector<unsigned int, false, <error-constant>>") is not allowed

          using __type = typename __match::__type;
                                  ^
            detected during:
              instantiation of class "std::__match_cv_qualifiers<_Qualified, _Unqualified, _IsConst, _IsVol> [with _Qualified=char32_t, _Unqualified=unsigned int, _IsConst=false, _IsVol=<error-constant>]" at line 1952
              instantiation of class "std::__make_unsigned_selector<_Tp, false, true> [with _Tp=char32_t]" at line 1986



  /usr/include/c++/15.1.1/type_traits(1843): error: incomplete type
  "std::__cv_selector<std::__make_unsigned_selector<wchar_t, true,
  false>::__unsigned_type, false, <error-constant>>" is not allowed

          using __type = typename __match::__type;
                                  ^
            detected during:
              instantiation of class "std::__match_cv_qualifiers<_Qualified, _Unqualified, _IsConst, _IsVol> [with _Qualified=wchar_t, _Unqualified=<error-type>, _IsConst=false, _IsVol=<error-constant>]" at line 1914
              instantiation of class "std::__make_unsigned_selector<_Tp, true, false> [with _Tp=wchar_t]" at line 2081
              instantiation of class "std::__make_signed_selector<_Tp, false, true> [with _Tp=wchar_t]" at line 2095



  /usr/include/c++/15.1.1/type_traits(2084): error: incomplete type
  "std::__make_signed_selector<std::__make_signed_selector<wchar_t, false,
  true>::__unsigned_type, false, <error-constant>>" is not allowed

          using __type = typename __make_signed_selector<__unsigned_type>::__type;
                                  ^
            detected during instantiation of class "std::__make_signed_selector<_Tp, false, true> [with _Tp=wchar_t]" at line 2095



  /usr/include/c++/15.1.1/type_traits(1843): error: incomplete type
  "std::__cv_selector<std::__make_unsigned_selector<wchar_t, true,
  false>::__unsigned_type, false, <error-constant>>" is not allowed

          using __type = typename __match::__type;
                                  ^
            detected during:
              instantiation of class "std::__match_cv_qualifiers<_Qualified, _Unqualified, _IsConst, _IsVol> [with _Qualified=char16_t, _Unqualified=<error-type>, _IsConst=false, _IsVol=<error-constant>]" at line 1914
              instantiation of class "std::__make_unsigned_selector<_Tp, true, false> [with _Tp=char16_t]" at line 2081
              instantiation of class "std::__make_signed_selector<_Tp, false, true> [with _Tp=char16_t]" at line 2111



  /usr/include/c++/15.1.1/type_traits(2084): error: incomplete type
  "std::__make_signed_selector<std::__make_signed_selector<wchar_t, false,
  true>::__unsigned_type, false, <error-constant>>" is not allowed

          using __type = typename __make_signed_selector<__unsigned_type>::__type;
                                  ^
            detected during instantiation of class "std::__make_signed_selector<_Tp, false, true> [with _Tp=char16_t]" at line 2111



  /usr/include/c++/15.1.1/type_traits(1843): error: incomplete type
  "std::__cv_selector<std::__make_unsigned_selector<wchar_t, true,
  false>::__unsigned_type, false, <error-constant>>" is not allowed

          using __type = typename __match::__type;
                                  ^
            detected during:
              instantiation of class "std::__match_cv_qualifiers<_Qualified, _Unqualified, _IsConst, _IsVol> [with _Qualified=char32_t, _Unqualified=<error-type>, _IsConst=false, _IsVol=<error-constant>]" at line 1914
              instantiation of class "std::__make_unsigned_selector<_Tp, true, false> [with _Tp=char32_t]" at line 2081
              instantiation of class "std::__make_signed_selector<_Tp, false, true> [with _Tp=char32_t]" at line 2118



  /usr/include/c++/15.1.1/type_traits(2084): error: incomplete type
  "std::__make_signed_selector<std::__make_signed_selector<wchar_t, false,
  true>::__unsigned_type, false, <error-constant>>" is not allowed

          using __type = typename __make_signed_selector<__unsigned_type>::__type;
                                  ^
            detected during instantiation of class "std::__make_signed_selector<_Tp, false, true> [with _Tp=char32_t]" at line 2118



  /usr/include/c++/15.1.1/type_traits(3302): error: type name is not allowed

        : public __bool_constant<__is_invocable(_Fn, _ArgTypes...)>
                                                ^



  /usr/include/c++/15.1.1/type_traits(3302): error: type name is not allowed

        : public __bool_constant<__is_invocable(_Fn, _ArgTypes...)>
                                                     ^



  /usr/include/c++/15.1.1/type_traits(3332): error: type name is not allowed

        : public __bool_constant<__is_nothrow_invocable(_Fn, _ArgTypes...)>
                                                        ^



  /usr/include/c++/15.1.1/type_traits(3332): error: type name is not allowed

        : public __bool_constant<__is_nothrow_invocable(_Fn, _ArgTypes...)>
                                                             ^



  /usr/include/c++/15.1.1/type_traits(3408): error: type name is not allowed

      inline constexpr bool is_pointer_v = __is_pointer(_Tp);
                                                        ^



  /usr/include/c++/15.1.1/type_traits(3521): error: type name is not allowed

      inline constexpr bool is_volatile_v = __is_volatile(_Tp);
                                                          ^



  /usr/include/c++/15.1.1/type_traits(3663): error: type name is not allowed

      inline constexpr size_t rank_v = __array_rank(_Tp);
                                                    ^



  /usr/include/c++/15.1.1/bits/stl_algobase.h(1239): error: type name is not
  allowed

        || __is_pointer(_ValueType1)
                        ^



  /usr/include/c++/15.1.1/bits/stl_algobase.h(1412): error: type name is not
  allowed

      && __is_pointer(_II1) && __is_pointer(_II2)
                      ^



  /usr/include/c++/15.1.1/bits/stl_algobase.h(1412): error: type name is not
  allowed

      && __is_pointer(_II1) && __is_pointer(_II2)
                                            ^



  25 errors detected in the compilation of "CMakeCUDACompilerId.cu".

  # --error 0x2 --





Call Stack (most recent call first):
  /usr/share/cmake/Modules/CMakeDetermineCompilerId.cmake:8 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
  /usr/share/cmake/Modules/CMakeDetermineCompilerId.cmake:53 (__determine_compiler_id_test)
  /usr/share/cmake/Modules/CMakeDetermineCUDACompiler.cmake:136 (CMAKE_DETERMINE_COMPILER_ID)
  cmake/FindDependencies.cmake:132 (enable_language)
  CMakeLists.txt:107 (include)


-- Configuring incomplete, errors occurred!
==> ERROR: A failure occurred in build().

I have tried everything I found on the internet. First, it was a mismatch between the GCC version and CUDA's required GCC (15 and 14). I tried symlinks, editing the pkgbuild and other things but to no avail.
I use an RTX 3070 with the nvidia proprietary driver on GNOME.

Offline

#2 2025-05-28 23:23:28

loqs
Member
Registered: 2014-03-06
Posts: 18,872

Re: Issues with CUDA and GCC

Which PKGBUILD generated the output you posted?

Offline

#3 2025-05-28 23:32:47

DrChelomey
Member
Registered: 2025-05-28
Posts: 2

Re: Issues with CUDA and GCC

loqs wrote:

Which PKGBUILD generated the output you posted?

The one from https://aur.archlinux.org/packages/colmap.
Here it is:

#!/bin/hint/bash
# Maintainer : bartus <arch-user-repoᘓbartus.33mail.com>

check_option "debug" "y" && BUILD_TYPE=Debug || BUID_TYPE=Release

## Configuration env vars:
_BUILD_CUDA="${BUILD_CUDA:-ON}"
_CUDA_ARCH="${CUDA_ARCH:-native}"
_fragment=${FRAGMENT:-#tag=3.11.1}
# Use CMAKE_FLAGS=xxx:yyy:zzz to define extra CMake flags
[[ -v CMAKE_FLAGS ]] && mapfile -t -d: _CMAKE_FLAGS < <(echo -n "$CMAKE_FLAGS")

_name=colmap
#fragment="#commit=5bea89263bf5f3ed623b8e6e6a5f022a0ed9c1de"
pkgname=${_name}
pkgver=3.11.1
pkgrel=1
pkgdesc="General-purpose Structure-from-Motion (SfM) and Multi-View Stereo (MVS) pipeline with a graphical and command-line interface."
arch=('i686' 'x86_64')
url="https://colmap.github.io/"
license=('GPL')
groups=()
depends=('cgal' 'ceres-solver' 'gflags' 'suitesparse' 'freeglut' 'glew' 'google-glog' 'freeimage' 'libjpeg' 'boost-libs' 'qt5-base' 'metis' 'flann')
makedepends=('boost' 'cmake' 'eigen' 'git' 'ninja' 'python-sphinx')
if [ "$_BUILD_CUDA" == "ON" ] ; then 
  makedepends+=('cuda')
  optdepends+=('libcudart.so: required for dense reconstruction')
fi
source=("${pkgname}::git+https://github.com/colmap/colmap.git${_fragment}"
        "vocabulary-tree-32K.bin::https://demuc.de/colmap/vocab_tree_flickr100K_words32K.bin"
        "vocabulary-tree-256K.bin::https://demuc.de/colmap/vocab_tree_flickr100K_words256K.bin"
        "vocabulary-tree-1M.bin::https://demuc.de/colmap/vocab_tree_flickr100K_words1M.bin"
        )
sha256sums=('9a6174cbfa00416b51590d4027f40e2ce95220ef73c678e468fb497303351c70'
            'd37d8f19ee0a49705c4c0b06967a08cedfed5cf86519eada3271497256732bc2'
            'd2055600452a531b5b0a62aa5943e1a07195273dc4eeebcf23d3a924d881d53a'
            'fb60f7ba8081ee5c278f03c62329a374d1b24136b374a49393b453db1529a8c6')

prepare() {
  git -C "$pkgname" cherry-pick -n 71cebde85b5ce290c93f67326eea7c1b1c0cea97
}


build() {
  # determine whether we can precompile CUDA kernels
    _CUDA_PKG=$(pacman -Qsq cuda 2>/dev/null) || true
    if [[ -n "$_CUDA_PKG" && "$_BUILD_CUDA" == "ON" ]]; then
  # determine whether we need to define cuda host compiler
      if _cuda_gcc=$(readlink /opt/cuda/bin/gcc) ; then
        [ -f "$_cuda_gcc" ] && export CUDAHOSTCXX="$_cuda_gcc"
      fi
      _CMAKE_FLAGS+=( -DCUDA_ENABLED=ON
                      -DCUDA_TOOLKIT_ROOT_DIR=/opt/cuda
                      -DCMAKE_CUDA_ARCHITECTURES="$_CUDA_ARCH"
                    )
    else
      _CMAKE_FLAGS+=( -DCUDA_ENABLED=OFF )
    fi

  _CMAKE_FLAGS+=( -DTESTS_ENABLED=OFF
                  -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
                  -DCMAKE_INSTALL_PREFIX=/usr )
  cmake "${_CMAKE_FLAGS[@]}" -G Ninja -S "$pkgname" -B build
# shellcheck disable=SC2046 # allow MAKEFLAGS to carry multiple flags.
  ninja -C "$srcdir/build" $(grep -oP -- '-+[A-z]+ ?[0-9]*'<<<"${MAKEFLAGS:--j1}")
}


package() {
  DESTDIR="${pkgdir}" ninja -C build install

# build manpage
  make -C "${pkgname}/doc" man BUILDDIR="$PWD" && \
  install -Dm644 man/colmap.1 -t "${pkgdir}/usr/share/man/man1"

  # install vocabulary trees for sequential,vocabulary matching
  install -d -m755 "${pkgdir}/usr/share/${_name}"
  for vocab_tree in "${srcdir}"/vocabulary-tree-*.bin ; do
    install -m644 "${vocab_tree}" "${pkgdir}/usr/share/${_name}/${vocab_tree##*/}"
  done
}
# vim:set ts=2 sw=2 et:

Offline

#4 2025-05-29 00:29:51

loqs
Member
Registered: 2014-03-06
Posts: 18,872

Re: Issues with CUDA and GCC

I could not reproduce the issue. I did encounter an error which I worked around by changing it to a warning `CXXFLAGS+=' -Wno-error=template-body'` this was fixed upstream by https://github.com/colmap/colmap/commit … 72e7b134e1 which does not cherry-pick cleanly onto 3.11.1.

Offline

Board footer

Powered by FluxBB