如何在 Windows 上将其他 c++ 编译器与 CUDA 一起使用?

2022-01-10 00:00:00 windows cuda c++ nvcc

我正在尝试使用 CUDA 构建一个简单的应用程序,我已经连续尝试了几个小时,但我无法让它在 Windows 上运行.nvcc 绝对拒绝在没有不支持我需要的东西的 Visual Studio 编译器的情况下进行编译.我尝试使用带有 clang 的 nvcc 进行构建,但它只是要求我使用 Visual Studio 的编译器.我也尝试过直接使用 clang,因为它现在支持 CUDA,但我收到此错误:

I'm trying to build a simple application with CUDA and I've been trying for hours on end and I just can't make it work on windows. nvcc absolutely refuses to compile without Visual Studio's compiler which doesn't support things I need. I tried building using nvcc with clang but It just asks me to use Visual Studio's compiler. I've also tried using clang directly since it now supports CUDA but I receive this error:

clang++.exe: error: Unsupported CUDA gpu architecture: compute_52

这对我来说毫无意义,因为我有 CUDA 工具包 7.5 版,而我的显卡是 GTX 970(其中两个).我已经在谷歌上广泛搜索了这个,到处我遇到这个人总是遇到的错误是他们的 CUDA 工具包是 <7.5.我现在正试图让像 VLA 这样简单的东西来处理这个 CUDA 应用程序,但我无法实现它......

This makes no sense to me because I have the CUDA toolkit version 7.5 and my graphics card is a GTX 970 (two of them). I have googled this extensively and everywhere I come across the error the person always has is their CUDA toolkit is < 7.5. I'm on the brink of tears right now trying to get something as simple as VLA to work on this CUDA application and I just can't achieve it...

推荐答案

CUDA windows 工具链 需要 Visual Studio C++ 编译器.您不能在该平台上使用其他任何东西.如果 VS 编译器不支持您在 CUDA 主机代码中所需的语言功能,您别无选择,只能更改平台或您的期望.

The CUDA windows toolchain requires the Visual Studio C++ compiler. You cannot use anything else on that platform. If the VS compiler doesn't support the language features you need within CUDA host code, you have no choice but to change platforms, or your expectations.

您仍然可以使用其他编译器编译非 CUDA 主机代码,然后使用 NVCC 和 VS 工具链链接该代码.

You can still potentially compile non-CUDA host code using another compiler and then link that code using NVCC and the VS toolchain.

相关文章