Cuda 使用cc更改Rust传递给nvcc的编译参数
我正在使用Cuda 使用cc更改Rust传递给nvcc的编译参数,cuda,linker,rust,ffi,nvcc,Cuda,Linker,Rust,Ffi,Nvcc,我正在使用cc将用C编写的CUDA内核链接到Rust。 这是我的build.rs文件: extern crate cc; fn main() { cc::Build::new() .cuda(true) .flag("-cudart=shared") .flag("-gencode") .flag("arch=compute_61,code=sm_61") .file("kernel/kernel.cu")
cc
将用C编写的CUDA内核链接到Rust。
这是我的build.rs文件:
extern crate cc;
fn main() {
cc::Build::new()
.cuda(true)
.flag("-cudart=shared")
.flag("-gencode")
.flag("arch=compute_61,code=sm_61")
.file("kernel/kernel.cu")
.compile("kernel/kernel.a");
}
我有一个错误:
正在运行:“nvcc”“-ccbin=c++”“-O0”“-Xcompiler”“-F函数节”
“-Xcompiler”“-fdata节”“-Xcompiler”“-fPIC”“-G”“-Xcompiler”
“-g”“-m64”“-Xcompiler”“-Wall”“-Xcompiler”“-Wextra”
“-cudart=shared”“-gencode”“arch=compute\u 61,code=sm\u 61”“-o”
“/home/ltei/Dev/workspace/rust\u cudnn/target/debug/build/rust\u cudnn-df924982e63c2363/out/kernel/kernel.o”
-c“kernel/kernel.cu”cargo:warning=包含在中的文件中
/usr/include/cuda_runtime.h:78:0,cargo:warning=from
:0:cargo:warning=/usr/include/host_config.h:119:2:
错误:#错误--不支持的GNU版本!gcc版本5之后
不支持!货物:警告=#错误--不支持的GNU版本!
不支持5以上的gcc版本!货物:警告=^~~~~
退出代码:1
我知道,如果我能将命令中的-ccbin=c++
更改为-ccbin=clang-3.8
,它会起作用,但我不知道怎么做
我还可以安装另一个版本的GCC,但我更喜欢第一个解决方案。您可以将
CXX
环境变量设置为您想要的任何值
CXX=这是我的cpp编译器货物版本
这将用作ccbin
的参数:
“nvcc”“-ccbin=这是我的cpp编译器”“-O0”“-Xcompiler”“-fffunction sections”“-Xcompiler”“-fdata sections”“-Xcompiler”“-fPIC”“-G”“-Xcompiler”“-G”“-m64”“-Xcompiler”“-Wall”“-Xcompiler”“-Wextra”“-cudart=shared”“-gencode”“arch=compute61,code=sm_61”“-o”“/private/tmp/c/target/debug/build/c-674cff35f35f3f5c/kernel/c/kernel.d1”-c“kernel/kernel.cu”
您的问题是如何更改rust传递给nvcc的编译参数?是的!我可以使用.flag(“…”)添加参数,但我无法更改-ccbin参数,因此您可以编辑问题标题和标记以反映您的问题。有没有一种方法可以做到这一点,而不必每次都写出环境变量,或将其放在我的bash配置文件中?我希望能够每天运行“货物运行”,而不是“CXX=/opt/cuda/bin货物运行”time@vcapra1你得看一下地图,看看有没有办法。考虑到它是一个环境变量,并且在每个平台或机器上都可能不同,硬编码任何值似乎都不是一个好主意。您还可以在构建脚本中尝试一下,看看是否能够使用它。