Error compiling CUDA from Command Prompt
Asked Answered
O

8

64

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?

Orthodoxy answered 14/11, 2011 at 17:49 Comment(1)
if you get another error "Cannot find corecrt.h" after fixing this issue, check out #38290669Vitrify
U
61

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).

Undercast answered 14/11, 2011 at 18:26 Comment(9)
Ok, but how do I add it? I'm used to work on linux, so I'm unused to the ways of windows now...Orthodoxy
Fine, but now I got another error: ` nvcc fatal : Visual Studio configuration file '(null)' could not be found for installation at 'C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin/../..' `Orthodoxy
Nevermind, I got rid of it just by passing --machine 32 as a parameter to nvccOrthodoxy
When I search for this file, I see different versions in different sizes. How can one determine which one belongs? Also, I tried adding the path of one to the Environment Variable, but I still get this error.Bari
@Jackalope: Which paths are you getting for cl.exe? It should be the one that ends with \bin.Undercast
@Jackalope Try to run vcvars.bat in the bin directory. It sets up some environment variables used by cl.exe.Odom
What should be the variable name? The key?Chandler
@notgiorgi: The variable name is PATH. Just append the path to cl.exe at the end of the existing value.Undercast
in my system there is no folder bin in VC, take a look : hereUnprejudiced
C
39

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

Canadianism answered 30/10, 2019 at 20:30 Comment(3)
So one has to add this path to Path in environment variables right ?Hilly
@Hilly yes. I tried adding the x64 one to the system PATH and it worked.Strobel
In 2022, the location is in C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\bin\Hostx64\x64Subaquatic
S
25

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

Swami answered 29/7, 2014 at 20:48 Comment(5)
Can you clarify what you mean by "edit this problem"?Psalm
Adding the `\VC\bin` folder to the PATH environment variable did not work for me (Win7). Your solution, however, worked just fine! I was trying to compile some code for MATLAB. Thanks!Grettagreuze
bro. study cuda toolkit to know all of this options and better work. It's our duty to help and answer each other. thanks you too.Swami
or a more recent path: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\binBrittaney
one occasion where neither path entries nor -ccbin will help either is when building for x86 but nvcc.exe won't support it for the given version of cl.exe (in my case: nvcc.exe from CUDA 10.0.130 won't build 32 bit binaries with cl.exe from VS2015)Philanthropist
A
5

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.

Aphanite answered 14/11, 2011 at 17:54 Comment(0)
M
2

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"

Moe answered 5/4, 2024 at 21:33 Comment(0)
C
1

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.

Correll answered 14/11, 2011 at 17:54 Comment(0)
T
1

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
Tadtada answered 24/12, 2022 at 7:59 Comment(1)
I am on the exact version that you are of MSVC but I still get the error. If I just run cl.exe I get no errorChirm
D
0

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.)

Dendrochronology answered 14/3, 2014 at 18:8 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.