GennSev
GennSev

Reputation: 1646

Error compiling CUDA from Command Prompt

I'm trying to compile a cuda test program on Windows 7 via Command Prompt, I'm this command:

nvcc test.cu

But all I get is this error:

nvcc fatal : Cannot find compiler 'cl.exe' in PATH

What may be causing this error?

Upvotes: 64

Views: 112739

Answers (8)

Tonecops
Tonecops

Reputation: 167

As of 2024 April 6th the location of VC 2022, cl.exe in 64 bit Windows 11 Pro version 23H2 is:

"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\ 14.38.33130\bin\Hostx64\x64\cl.exe"

Upvotes: 2

Arnab Das
Arnab Das

Reputation: 157

Solve this problem by adding the path to environment variables, which can vary slightly depending in the version of visual studio installed in your system, and are you using 32bit or 64bit system

C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\Hostx64\x64

Upvotes: 1

Samarth Janardhan
Samarth Janardhan

Reputation: 391

For new Visual Studio cl.exe is present in path => C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx64\x64

x64 is for 64bit

x86 is for 32bit

Upvotes: 39

Tudor
Tudor

Reputation: 62459

You will need to add the folder containing the "cl.exe" file to your path environment variable. For example:

C:\Program Files\Microsoft Visual Studio 10.0\VC\bin

Edit: Ok, go to My Computer -> Properties -> Advanced System Settings -> Environment Variables. Here look for "PATH" in the list, and add the path above (or whatever is the location of your cl.exe).

Upvotes: 62

Prof. Hell
Prof. Hell

Reputation: 809

Solve this problem by adding this options to nvcc

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

for example my compiler is VS2012. and cl.exe is in this dir

Upvotes: 25

Donna
Donna

Reputation: 41

I see that this is an old question but I recently got this error on my Visual Studio 2012 when I tried to build my CUDA project. Apparently I had changed my CUDA project to the Nov 2012 pack, changing it back to the v110 that it usually is by default fixed this error.

In Visual Studio, left click on the CUDA project, ->properties->Configuration Properties-> General -> Platform toolset, and choose: Visual Studio 2012 (v110).

I could probably get it to work with the Nov 2012 pack, but the CUDA code does not use any of the additional functions of that pack, so it is not necessary. (That pack contains the variadic templates for C++11.)

Upvotes: 0

Steve Fallows
Steve Fallows

Reputation: 6424

nvcc is only a front end for the CUDA specific part of the program. It must invoke a full compiler to finish the job. In this case it cannot find the Visual Studio compiler 'cl.exe'

Check paths, nvcc documentation etc.

Upvotes: 1

Chris Dodd
Chris Dodd

Reputation: 126468

cl.exe is Microsoft's C/C++ compiler. So the problem is that you don't have that installed where the command line can find it.

Upvotes: 5

Related Questions