windows 在没有 Visual Studio 的情况下编译 CUDA - “在路径中找不到编译器 cl.exe”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8985860/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 09:08:29  来源:igfitidea点击:

Compile CUDA without Visual Studio - "Cannot find compiler cl.exe in path"

windowsparallel-processingcuda

提问by Panos Kal.

I've just begun a small project in CUDA.

我刚刚在 CUDA 中开始了一个小项目。

I need to know the following: Is it possible to compile CUDA code without using/buying Microsoft Visual Studio? Using Nvcc.exe I get the error "Cannot find compiler cl.exe in path".

我需要了解以下内容:是否可以在不使用/购买 Microsoft Visual Studio 的情况下编译 CUDA 代码?使用 Nvcc.exe 我收到错误“在路径中找不到编译器 cl.exe”。

I've tried to install a CUDA pluginfor NetBeans, but it doesn't work. (with current version of NetBeans)

我尝试为 NetBeans安装 CUDA插件,但它不起作用。(使用当前版本的 NetBeans)

Platform: Windows 7

平台:Windows 7

Thanks in advance.

提前致谢。

采纳答案by Panos Kal.

Following the previous comments I've installed Studio Express & VS2010. This did not solve the "cl.exe not in path" problem.

按照之前的评论,我已经安装了 Studio Express & VS2010。这并没有解决“cl.exe 不在路径中”的问题。

I solved the problem with the error Cannot find compiler cl.exe in path, by including c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64in PATH, before installing Windows SDK.

在安装 Windows SDK 之前Cannot find compiler cl.exe in path,我通过包含 c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64在 PATH 中解决了错误问题。

This questionalso contains valuable information.
For some reason VS2010& Studio Expressfailed to set the proper variables in path even after the execution of vsvars32.bat.

这个问题也包含有价值的信息。
出于某种原因VS2010Studio Express即使在执行vsvars32.bat.

Thank you all for your valuable help.

感谢大家的宝贵帮助。

回答by arx

Update

更新

As noted in the comments, versions of the SDK after Windows 7's do not include the build tools. If you want to use Microsoft's most recent tools you have to install Visual Studio. Once installed, you can use the tools from the command-line.

如评论中所述,Windows 7 之后的 SDK 版本不包括构建工具。如果您想使用 Microsoft 的最新工具,您必须安装 Visual Studio。安装后,您可以从命令行使用这些工具。

At the moment the free versions are the "Community" versions, e.g. Microsoft Visual Studio Community 2015.

目前免费版本是“社区”版本,例如Microsoft Visual Studio Community 2015

You can continue to develop apps for Windows 7 and earlier (and they will run on later versions of Windows) using the old SDK tools as I described before:

您可以继续使用我之前描述的旧 SDK 工具为 Windows 7 及更早版本(它们将在更高版本的 Windows 上运行)开发应用程序:

Original Answer

原答案

If you desperately want to avoid Visual Studio, download and install the Windows SDK. This contains (more or less) the same build tools as Visual Studio.

如果您非常想避免使用 Visual Studio,请下载并安装Windows SDK。这包含(或多或少)与 Visual Studio 相同的构建工具。

Then run the Windows SDK Command Prompt (which you'll find on the start menu under Microsoft Windows SDK) to set the path to point to the tools, and you are set.

然后运行 ​​Windows SDK 命令提示符(您可以在 Microsoft Windows SDK 下的开始菜单上找到它)设置指向工具的路径,然后就设置好了。

Or just use Visual C++ Express.

或者只是使用 Visual C++ Express。

回答by Prof. Hell

add this options to nvcc

将此选项添加到 nvcc

nvcc x.cu <other options>  -ccbin "D:\Program Files\Microsoft Visual Studio 11.0\VC\bin"

i use VS2012 and my cl.exe dir is here.

我使用 VS2012,我的 cl.exe 目录在这里。

回答by captain

You have to figure out where NVIDIA GPU Computing Toolkit is installed. In my system it's in "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe" Then

您必须弄清楚 NVIDIA GPU Computing Toolkit 的安装位置。在我的系统中,它位于“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe”然后

  1. "Edit Environment Variables" on Windows.
  2. Click on New...
  3. Variable name: NVCC Variable Value: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe
  4. Click on OK.
  1. Windows 上的“编辑环境变量”。
  2. 点击新建...
  3. 变量名称:NVCC 变量值:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe
  4. 单击确定。

回答by Rahul Gogoi

Use windows subsystem for linux and install ubuntu and nvcc along with gcc and g++ using the ubuntu terminal in windows (gui does not works for linux subsystem for windows). Then configure .bashrc using bash and vim/nano with a 'cd' command to your desired location as it is done in usual linux terminal (makes it easy as bash opens in system32 folder everytime). And then you can compile .cu files using nvcc over bash. As nvcc supports gcc and g++ under linux so it solves the problem. No need to sacrifice peace for switching over to linux or dealing with crappy visual studio. It worked for me.

为 linux 使用 windows 子系统,并在 windows 中使用 ubuntu 终端安装 ubuntu 和 nvcc 以及 gcc 和 g++(gui 不适用于 windows 的 linux 子系统)。然后使用 bash 和 vim/nano 将 .bashrc 配置到您想要的位置,就像在通常的 linux 终端中完成的那样(因为 bash 每次都在 system32 文件夹中打开,所以很容易)。然后你可以通过 bash 使用 nvcc 编译 .cu 文件。由于 nvcc 在 linux 下支持 gcc 和 g++,所以它解决了这个问题。无需为切换到 linux 或处理糟糕的视觉工作室而牺牲和平。它对我有用。

enter image description here

在此处输入图片说明