Solve colmap cuda CMakeCUDACompilerId.cu error under arch

If you get an error similar to this when installing colmap under arch or manjaro:

1
2
3
4
5
6
7
8
9
10
  Compiling the CUDA compiler identification source file
"CMakeCUDACompilerId.cu" failed.

...

/usr/include/c++/14.1.1/x86_64-pc-linux-gnu/bits/c++config.h(827): error:
user-defined literal operator not found

typedef __decltype(0.0bf16) __bfloat16_t;

Maybe these steps can help you:

1. Install gcc-13

1
yay -S gcc13

2. Export CUDAHOSTCXX and yay

1
2
export CUDAHOSTCXX=/usr/bin/g++-13
yay -S colmap

My full error message

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
CMake Error at /home/myuan/.pyenv/versions/3.11.3/lib/python3.11/site-packages/cmake/data/share/cmake-3.26/Modules/CMakeDetermineCompilerId.cmake:751 (message):
Compiling the CUDA compiler identification source file
"CMakeCUDACompilerId.cu" failed.

Compiler: /opt/cuda/bin/nvcc

Build flags:

Id flags: --keep;--keep-dir;tmp -v



The output was:

2

#$ _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

#$ CICC_NEXT_PATH=/opt/cuda/bin/../nvvm-next/bin

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

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

#$
PATH=/opt/cuda/bin/../nvvm/bin:/opt/cuda/bin:/home/myuan/.pyenv/versions/3.11.3/bin:/usr/share/pyenv/libexec:/usr/share/pyenv/plugins/python-build/bin:/home/myuan/.vscode-server/extensions/ms-python.python-2024.8.1/python_files/deactivate/fish:/home/myuan/projects/ssdna-totalRNA-registration/.venv/bin:/home/myuan/.pyenv/shims:/home/myuan/.cargo/bin:/opt/vcpkg:/opt/cuda/bin:/home/myuan/.local/bin:/home/myuan/projects/ANTs-bin/bin:/home/myuan/.vscode-server/extensions/ms-python.python-2024.8.1/python_files/deactivate/fish:/home/myuan/projects/ssdna-totalRNA-registration/.venv/bin:/home/myuan/.vscode-server/cli/servers/Stable-ea1445cc7016315d0f5728f8e8b12a45dc0a7286/server/bin/remote-cli:/usr/local/sbin:/usr/local/bin:/usr/bin:/var/lib/snapd/snap/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

#$ 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__=5
-D__CUDACC_VER_BUILD__=40 -D__CUDA_API_VER_MAJOR__=12
-D__CUDA_API_VER_MINOR__=5 -D__NVCC_DIAG_PRAGMA_SUPPORT__=1 -include
"cuda_runtime.h" -m64 "CMakeCUDACompilerId.cu" -o
"tmp/CMakeCUDACompilerId.cpp4.ii"

#$ cudafe++ --c++17 --gnu_version=140101 --display_error_number
--orig_src_file_name "CMakeCUDACompilerId.cu" --orig_src_path_name
"/home/myuan/.cache/yay/colmap/src/build/CMakeFiles/3.26.3/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++/14.1.1/x86_64-pc-linux-gnu/bits/c++config.h(827): error:
user-defined literal operator not found

typedef __decltype(0.0bf16) __bfloat16_t;
^



/usr/include/c++/14.1.1/type_traits(529): error: type name is not allowed

: public __bool_constant<__is_array(_Tp)>
^



/usr/include/c++/14.1.1/type_traits(529): error: identifier "__is_array" is
undefined

: public __bool_constant<__is_array(_Tp)>
^



/usr/include/c++/14.1.1/type_traits(581): error: type name is not allowed

: public __bool_constant<__is_member_object_pointer(_Tp)>
^



/usr/include/c++/14.1.1/type_traits(581): error: identifier
"__is_member_object_pointer" is undefined

: public __bool_constant<__is_member_object_pointer(_Tp)>
^



/usr/include/c++/14.1.1/type_traits(603): error: type name is not allowed

: public __bool_constant<__is_member_function_pointer(_Tp)>
^



/usr/include/c++/14.1.1/type_traits(603): error: identifier
"__is_member_function_pointer" is undefined

: public __bool_constant<__is_member_function_pointer(_Tp)>
^



/usr/include/c++/14.1.1/type_traits(695): error: type name is not allowed

: public __bool_constant<__is_reference(_Tp)>
^



/usr/include/c++/14.1.1/type_traits(695): error: identifier
"__is_reference" is undefined

: public __bool_constant<__is_reference(_Tp)>
^



/usr/include/c++/14.1.1/type_traits(731): error: type name is not allowed

: public __bool_constant<__is_object(_Tp)>
^



/usr/include/c++/14.1.1/type_traits(731): error: identifier "__is_object"
is undefined

: public __bool_constant<__is_object(_Tp)>
^



/usr/include/c++/14.1.1/type_traits(760): error: type name is not allowed

: public __bool_constant<__is_member_pointer(_Tp)>
^



/usr/include/c++/14.1.1/type_traits(760): error: identifier
"__is_member_pointer" is undefined

: public __bool_constant<__is_member_pointer(_Tp)>
^



/usr/include/c++/14.1.1/type_traits(3247): error: type name is not allowed

inline constexpr bool is_array_v = __is_array(_Tp);
^



/usr/include/c++/14.1.1/type_traits(3271): error: type name is not allowed

__is_member_object_pointer(_Tp);
^



/usr/include/c++/14.1.1/type_traits(3281): error: type name is not allowed

__is_member_function_pointer(_Tp);
^



/usr/include/c++/14.1.1/type_traits(3298): error: type name is not allowed

inline constexpr bool is_reference_v = __is_reference(_Tp);
^



/usr/include/c++/14.1.1/type_traits(3315): error: type name is not allowed

inline constexpr bool is_object_v = __is_object(_Tp);
^



/usr/include/c++/14.1.1/type_traits(3328): error: type name is not allowed

inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp);
^



/usr/include/c++/14.1.1/bits/utility.h(237): error: __type_pack_element is
not a template

{ using type = __type_pack_element<_Np, _Types...>; };
^



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

# --error 0x2 --





Call Stack (most recent call first):
/home/myuan/.pyenv/versions/3.11.3/lib/python3.11/site-packages/cmake/data/share/cmake-3.26/Modules/CMakeDetermineCompilerId.cmake:8 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
/home/myuan/.pyenv/versions/3.11.3/lib/python3.11/site-packages/cmake/data/share/cmake-3.26/Modules/CMakeDetermineCompilerId.cmake:53 (__determine_compiler_id_test)
/home/myuan/.pyenv/versions/3.11.3/lib/python3.11/site-packages/cmake/data/share/cmake-3.26/Modules/CMakeDetermineCUDACompiler.cmake:307 (CMAKE_DETERMINE_COMPILER_ID)
cmake/FindDependencies.cmake:118 (enable_language)
CMakeLists.txt:85 (include)


-- Configuring incomplete, errors occurred!
==> 错误: 在 build() 中发生一个错误。
正在放弃...
-> 生成时出错: colmap-exit status 4
-> 无法安装以下软件包, 需要手动介入处理:
colmap - exit status 4