gpt4 book ai didi

c++ - 如何使用 Clang 的 CUDA 编译器?

转载 作者:搜寻专家 更新时间:2023-10-31 02:06:45 27 4
gpt4 key购买 nike

我在 Ubuntu 17.10 上。我安装了 NVIDIA 的 CUDA 9.1 SDK。

这是我尝试过的:

~/GrinGoldMiner/src/Cudacka$ clang++-5.0 -Wl,--cuda-path=/usr/local/cuda-9.1 kernel.cu
clang: error: cannot find libdevice for sm_20. Provide path to different CUDA installation via --cuda-path, or pass -nocudalib to build without linking with libdevice.
clang: error: cannot find CUDA installation. Provide its path via --cuda-path, or pass -nocudainc to build without CUDA includes.
clang: error: cannot find CUDA installation. Provide its path via --cuda-path, or pass -nocudainc to build without CUDA includes.

显然这行不通。似乎链接器标志没有通过。我怎样才能正确传递它们?

最佳答案

好像clang++-5.0不支持CUDA 9.X ...

clang++ 能够使用 CUDA 8.0 编译 CUDA 内核:

$ clang++-5.0 -O0 -g --cuda-gpu-arch=sm_50 --cuda-path=/usr/local/cuda-8.0 -o t1 t1.cu -L/usr/local/cuda-8.0/lib64 -lcudart

但是在使用 CUDA 9.X 时我得到了和你一样的错误:

$ clang++-5.0 --cuda-gpu-arch=sm_50 --cuda-path=/usr/local/cuda-9.0 -o t1 t1.cu -L/usr/local/cuda-9.0/lib64 -lcudart
clang: error: cannot find libdevice for sm_50. Provide path to different CUDA installation via --cuda-path, or pass -nocudalib to build without linking with libdevice.

他们在此提交中添加了对 Volta (sm_70) 和 CUDA 9.0 的支持:6d4cb40 .在 2017 年,这仅在 master 分支上可用,您可以这样确认它:

$ git clone https://github.com/llvm-mirror/clang.git 
$ cd clang/
$ git branch --contains 6d4cb40
* master

$ git checkout release_50
Branch release_50 set up to track remote branch release_50 from origin.
Switched to a new branch 'release_50'
$ git log | grep 6d4cb40
$ (output was empty)

请注意,clang(7.0.0,2018 年 9 月发布)支持 CUDA 7.0 到 9.2。

关于c++ - 如何使用 Clang 的 CUDA 编译器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49780373/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com