I keep getting the following error when I try to compile with nvcc from a Windows command line:
nvcc fatal: Could not set up environment for Microsoft Visual Studio using ‘E:/VisualStudio/VC/bin//…/…/VC/bin/amd64/vcvars64.bat’
I understand that a similar problem has been brought up in this forum many times in the past…the difference being that this time, that file definitely does exist. I expect that perhaps it is because the compiler is using ‘/’ instead of '' and the command line compiler is being futzy about it? Is there a way to set this, or am I possibly missing an obvious nvcc command-line option to fix this?
The path used by nvcc looks like it is composited from multiple fragments, possibly using the VCINSTALLDIR or VSINSTALLDIR environment variables. On my Windows 7 system, I have this in my environment:
VSINSTALLDIR=c:\Program Files (x86)\Microsoft Visual Studio 10.0
VCINSTALLDIR=c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC
PATH=[…];c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\amd64;[…]
I wonder whether your system may be missing one of these environment variables, or have inconsistent settings if they do exist. I also see a double slash “//” in your path. Not sure whether this could be a problem, but it could be an indication of incorrect compositing of the path or that one of the path components has a trailing slash when it shouldn’t have.
I’m having the exact same problem - CUDA 7.5, Visual Studio 2013, Windows 10.
The error message states: nvcc fatal : Could not set up the environment for Microsoft Visual Studio using ‘C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/…/…/VC/bin/amd64/vcvars64.bat’
There are no double slashes or anything, the file is of course in that directory. I read other threads that metioned the missing .bat files, which I added as a precaution - that didn’t help either.
Could a developer go ahead and check what specific environment variable does nvcc look at when trying to run this .bat file, and what exactly is the problem there?
There’s a lot of people reporting this issue, so I think that fixing it would really make that first CUDA experience much more pleasant, and a lot of people - myself included - would be very happy to see it in a patch.
I hope that helps someone, it appears the default batch file in my install runs into errors with nested parenthesis caused by variable expansion. I fixed it with a couple “!” in the first “if” statement of my batch file.
I guess it is the file from VS2013 distribution. But unfortunately I’m using VS2015. I haven’t found any troubles with parentheses in my file and I still have the problem described by the topic starter. :(
Yes, that was the file from the VS2013 distribution.
I figured my solution out by running the bat file inside a command prompt by itself. It gave a few errors for me when I looked closely. You might try that with VS2015’s bat file and see if you can come upon a problem.
[edit]
I also have VS2015 installed, I ran my vcvars64.bat, no output was given (meaning it ran successfully) you may have a different experience though.
When I running with bat file, I get the error:
nvcc fatal : Could not set up the environment for Microsoft Visual Studio using ‘C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/…/…/…/VC/bin/amd64/vcvars64.bat’
Finally, I added " --use-local-env --cl-version 2013" to CUDA_FLAGS1 variable, it’s work successfully.
It like this:
Same problem for me. I am working on Windows 10 Pro and I have installed Microsoft Visual Studio 2017 Enterprise and Cuda 9.2. I am trying to compile a .cu file with cmd because the integration of Cuda in Visual Studio didn’t worked. Even when I reinstalled my grafic driver and cuda like it was described here:
It is not working.
So I am trying it with the cmd command now.
When It type in cmd: nvcc hello.cu
I always get the message:
nvcc fatal : Could not set up the environment for Microsoft Visual Studio using ‘C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/…/…/VC/bin/amd64/vcvars64.bat’
I tryed already the solution from TylerHartwig with the ! but this had no effect. But I am not sure if I did this right. I was doing these changes in the vcvars64.bat file
What can I do. I am a absolutely newby, so please be patient
After some digging around I found that I get this error if there are any directories in the PATH,INCLUDE,LIB,LIBPATH env variables that have double quotes around them. Make sure that there are no quotes in any of these environment variables.