10

I've just begun a small project in 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".

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

Platform: Windows 7

Thanks in advance.

Panos Kalatzantonakis
  • 12,525
  • 8
  • 64
  • 85
  • 1
    What compiler do you want to use then? – flipchart Jan 24 '12 at 12:20
  • Yes you can do it without any IDE. You can set nvcc as your environment variable. – captain Jan 24 '12 at 13:06
  • @flipchart, I would like to use any free compiler available. I thought that nvcc was enough but it asks for cl.exe. – Panos Kalatzantonakis Jan 24 '12 at 13:34
  • @Jay, Can you please guide me. How can I make nvcc stop asking for cl.exe – Panos Kalatzantonakis Jan 24 '12 at 13:34
  • 2
    @Kabamaru: nvcc isn't a compiler, it requires a host compiler. AFAIK it is not possible to compile and run CUDA code on Windows platforms without using the microsoft compiler. You can use it without Visual Studio, but you cannot use gcc or anything else in place of cl.exe. – talonmies Jan 24 '12 at 13:51
  • 2
    Kabamaru, nvcc is compatible with [Express Edition](http://en.wikipedia.org/wiki/Microsoft_Visual_Studio_Express), which is free to use. (2008 from ISO is free; 2010 requires free registration after 30 days) – osgx Jan 24 '12 at 13:54
  • 1
    @talonmies I've seen some bindings for cuda made for languages outside of C and C++ but they don't mention `nvcc.exe` or `cl.exe` as a requirement. But from what you describe, it sounds impossible to use cuda in a different language. – greatwolf May 19 '14 at 20:35

5 Answers5

9

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.

At the moment the free versions are the "Community" versions, e.g. 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:

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.

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.

Or just use Visual C++ Express.

arx
  • 16,686
  • 2
  • 44
  • 61
  • 1
    What is download size (real size, not a 500 KB listed at linked page)? Which version of cl.exe is included? -- up to 600 MB (ISO download) and VS 2010. Here are release notes http://download.microsoft.com/download/E/0/3/E03C84A2-C25B-429F-B018-0C8B8B0C5009/ReleaseNotes_Win7_1RTMSDK.Htm – osgx Jan 24 '12 at 15:45
  • 1
    @osgx: I've got the 7.1 SDK and VC++ 2010 Express installed. They both have cl.exe version 16.00.30319.01. The download for the SDK was big, but I couldn't tell you the exact size. The 600MB mentioned in the release notes is plausible. – arx Jan 24 '12 at 16:03
  • 1
    Windows 8 SDK no longer includes a command-line build environment. http://msdn.microsoft.com/en-us/windows/hardware/hh852363.aspx – mcmillab Dec 16 '12 at 03:26
  • 1
    8 and 10 don't include cl.exe anymore. Where should windows 8 and 10 users get the command line build environment? – Stephen Smith Nov 18 '15 at 16:32
7

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

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\amd64 in PATH, before installing Windows SDK.

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

Thank you all for your valuable help.

Community
  • 1
  • 1
Panos Kalatzantonakis
  • 12,525
  • 8
  • 64
  • 85
  • 1
    vsvars32.bat does set the proper variables in the path, but only in the context of that command-prompt; it is not intended to set the variables system-wide. If you want a process to make use of the variables you have to launch the process from the command-prompt. – arx Feb 17 '12 at 16:55
  • 1
    One more thing related to this problem. I've been getting the same error (cl.exe not found in PATH) even though it was added in the user and sys variables. It turned out that the problem was with having two different Visual Studio versions (2012 and 2013). After uninstalling 2013 it compiles and runs in 2012 now (so might also compile in other IDEs - just tested in SharpDevelop and it works!). – Val Mar 03 '15 at 09:04
6

add this options to 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.

Prof. Hell
  • 729
  • 12
  • 19
2

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

  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.
captain
  • 815
  • 14
  • 26
1

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.

enter image description here

AStopher
  • 4,207
  • 11
  • 50
  • 75
  • 1
    Hi @rahul, Welcome to Stack Overflow Please try to make your answers more readable. i.e. Leave spaces and lines between important points. Also there is an 'enter image description here' that you could clean up. Keep the answers coming bro – Jacques Ramsden Feb 25 '19 at 22:50