gpt4 book ai didi

cuda - 使用 cc 更改 Rust 传递给 nvcc 的编译参数

转载 作者:行者123 更新时间:2023-11-29 08:14:03 25 4
gpt4 key购买 nike

我正在使用 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");
}

我有这个错误:

running: "nvcc" "-ccbin=c++" "-O0" "-Xcompiler" "-ffunction-sections" "-Xcompiler" "-fdata-sections" "-Xcompiler" "-fPIC" "-G" "-Xcompiler" "-g" "-m64" "-Xcompiler" "-Wall" "-Xcompiler" "-Wextra" "-cudart=shared" "-gencode" "arch=compute_61,code=sm_61" "-o" "/home/ltei/Dev/Workspaces/rust_cudnn/target/debug/build/rust_cudnn-df924982e63c2363/out/kernel/kernel.o" "-c" "kernel/kernel.cu" cargo:warning=In file included from /usr/include/cuda_runtime.h:78:0, cargo:warning= from :0: cargo:warning=/usr/include/host_config.h:119:2: error: #error -- unsupported GNU version! gcc versions later than 5 are not supported! cargo:warning= #error -- unsupported GNU version! gcc versions later than 5 are not supported! cargo:warning= ^~~~~ exit code: 1

我知道如果我可以将命令中的 -ccbin=c++ 更改为 -ccbin=clang-3.8 就可以了,但我不知道该怎么做做吧。

我也可以安装另一个版本的 GCC,但我更喜欢第一个解决方案。

最佳答案

您可以将 CXX 环境变量设置为您想要的任何值。

CXX=this-is-my-cpp-compiler cargo build

这将用作 ccbin 的参数:

"nvcc" "-ccbin=this-is-my-cpp-compiler" "-O0" "-Xcompiler" "-ffunction-sections" "-Xcompiler" "-fdata-sections" "-Xcompiler" "-fPIC" "-G" "-Xcompiler" "-g" "-m64" "-Xcompiler" "-Wall" "-Xcompiler" "-Wextra" "-cudart=shared" "-gencode" "arch=compute_61,code=sm_61" "-o" "/private/tmp/c/target/debug/build/c-67ec4fdcff2f35d1/out/kernel/kernel.o" "-c" "kernel/kernel.cu"

关于cuda - 使用 cc 更改 Rust 传递给 nvcc 的编译参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49342835/

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