将 CUDA 8.0 与 GCC 6.x 结合使用 - 错误的函数重载投诉

Using CUDA 8.0 with GCC 6.x - bad function overloading complaint

我正在尝试使用 GCC 6.2.1 构建一些 CUDA 代码,GCC 6.2.1 是我的发行版的默认编译器(注意:不是 CUDA 正式支持的 GCC 版本,因此您可以称之为实验性的)。这是使用 GCC 4.9.3 和 CUDA 版本 7.5 和 8.0 构建良好的代码。

好吧,如果我构建以下(接近)最小示例:

#include <tuple>

int main() { return 0; }

使用命令行

nvcc -std=c++11 -Wno-deprecated-gpu-targets -o main main.cu

我收到以下错误:

/usr/local/cuda/bin/../targets/x86_64-linux/include/math_functions.h(8897): error: cannot overload functions distinguished by return type alone

/usr/local/cuda/bin/../targets/x86_64-linux/include/math_functions.h(8901): error: cannot overload functions distinguished by return type alone

2 errors detected in the compilation of "/tmp/tmpxft_000071fe_00000000-9_b.cpp1.ii".

这是为什么?我怎么能correct/circumvent这个?

TL;DR:算了吧。仅将 CUDA 8.x 与 GCC 5.x 一起使用,将 CUDA 9 或更高版本与 GCC 6.x

一起使用

似乎 other people have seen this issue with GCC 6.1.x 并且建议将以下标志添加到 nvcc:-Xcompiler -D__CORRECT_ISO_CPP11_MATH_H_PROTO(是的,两个连续的标志;有关详细信息,请参阅 nvcc --help)。 (但我不能报告完全成功,因为会弹出其他问题。)

但请记住,GCC 5.4.x 是最新的受支持版本,这可能有充分的理由,因此将 GCC 6.x 强加到它上有点徒劳无功 - 特别是当 CUDA 9 现在可用时。