在 CUDA 11.5 中使用推力的 nvcc 编译错误

问题描述 投票:0回答:2

我最初在尝试编译包含

<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
c++ cuda thrust
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

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后,问题解决了。

© www.soinside.com 2019 - 2024. All rights reserved.