在CUDA 11.5中使用Thrust时出现nvcc编译错误

4

我最初询问编译包含<algorithm>的代码时出现的错误,但是通过添加标志-std=c++14解决了这个问题,例如nvcc -std=c++14 test1.cu。然而,现在在包含来自<thrust>的内容时,我得到了相同的错误消息。

#include <algorithm>
#include <thrust/extrema.h> // code compiles without this
int main(){
    return 0;
}

错误信息是:
/usr/include/c++/11/bits/std_function.h:435:145: error: parameter packs not expanded with ‘...’:
  435 |         function(_Functor&& __f)
      |                                                                                                                                                 ^ 
/usr/include/c++/11/bits/std_function.h:435:145: note:         ‘_ArgTypes’
/usr/include/c++/11/bits/std_function.h:530:146: error: parameter packs not expanded with ‘...’:
  530 |         operator=(_Functor&& __f)
      |                                                                                                                                                  ^ 
/usr/include/c++/11/bits/std_function.h:530:146: note:         ‘_ArgTypes’

这里有什么问题?
我使用以下版本。
- Ubuntu 22.04.1 LTS - Cuda编译工具,版本11.5,V11.5.119 - gcc(Ubuntu 11.3.0-1ubuntu1~22.04)11.3.0 - g++(Ubuntu 9.5.0-1ubuntu1~22.04)11.3.0

1
你声称正在使用g++ 9.5,但错误显示g++11标准库包含失败。你真的确定你的g++9安装没有问题吗? - talonmies
@talonmies 这可能是情况。有什么我可以做来解决这个问题吗?我尝试了 g++ 11.3.0,但得到了完全相同的错误。 - Kaz
2
您刚发布的更新恰好是我在这个版本的CUDA(也适用于Ubuntu 22.04上的gcc 11.3)遇到的一个错误。我升级到了11.7,问题得到了解决。 - Erel
1
@Erel 我尝试了CUDA 11.8,最终它成功了。非常感谢你让我知道! - Kaz
2个回答

4
这是一个特定版本CUDA的错误,正如评论中指出的那样。这些版本的组合解决了这个问题。
  • Ubuntu 22.04.1 LTS
  • CUDA编译工具,发布11.8,V11.8.89
  • gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
  • g++ (Ubuntu 9.5.0-1ubuntu1~22.04) 11.3.0

1
我在Ubuntu 22.04上通过使用nvcc 11.5和GCC 10.5.0(g++-10软件包)解决了这个问题。 - undefined

0
我遇到了与这些版本相同的问题。
nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Thu_Nov_18_09:45:30_PST_2021
Cuda compilation tools, release 11.5, V11.5.119
Build cuda_11.5.r11.5/compiler.30672275_0

gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

更新到nvcc 11.8之后,问题得到解决。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接