Unable to compile CUDA file, complains about no source file

I am unable to compile my cuda source file. My machine complains about no file or directory but I obviously have a file.

I need help, I’m not sure where to go from here. Below is the error i get

C:\projects\cuda\vs-test\vs-test>nvcc kernel.cu
kernel.cu
c1xx : fatal error C1083: Cannot open source file: 'kernel.cu': No such file or directory

C:\projects\cuda\vs-test\vs-test>dir
 Volume in drive C is Windows
 Volume Serial Number is 8CC9-A2A8

 Directory of C:\projects\cuda\vs-test\vs-test

05/22/2017  02:05 PM    <DIR>          .
05/22/2017  02:05 PM    <DIR>          ..
05/22/2017  02:05 PM    <DIR>          Debug
05/22/2017  02:04 PM             3,816 kernel.cu
05/22/2017  02:04 PM             8,627 vs-test.vcxproj
               2 File(s)         12,443 bytes
               3 Dir(s)  784,315,928,576 bytes free

See this topic for a possible solution, specifically post #11:

https://devtalk.nvidia.com/default/topic/978822/nvcc-on-windows/

It looks like the syntax you are passing to nvcc is not what it expects, basically.

vacaloca, that doesn’t do anything for me, I dont think its a syntax issue.

C:\projects\cuda>nvcc -o helloWorld.exe -arch=sm_50 helloWorld.cu
helloWorld.cu
c1xx : fatal error C1083: Cannot open source file: 'helloWorld.cu': No such file or directory

C:\projects\cuda>

It’s possible your environment is not set up correctly somehow. By default cl.exe (the Visual Studio compiler) is not on the path, and you would normally get something like ‘cl.exe not found in path’, until you define the path to where it lives. When I added the path to the x64 compiler on my machine which is, in my case,

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64

it worked fine. Perhaps you have the path to cl.exe set to some other compiler that is not the correct architecture, hard to say.

It could also be perhaps a mismatch between nvcc and cl.exe versions perhaps and the error that comes up isn’t descriptive, not sure. You might want to look at which nvcc.exe and cl.exe binaries are actually being called as per your path settings.

Edit: Call nvcc and pass the -v (verbose flag). That will show the variables and full command lines that are executed… chances are one of them is very wrong.

Ok I had this same error, I figured out a solution but honestly have no idea why it worked. I was trying to compile in a partitioned drive (E:) and as soon as I instead compiled on the main drive (C:) it worked.

I double checked by moving a cuda sample which compiled fine on C:, which then stopped functioning on E:.

But given this is where the OP was trying all along I can’t really offer any more help.

I’m running on W10, with CUDA 10 and VS2017, all updated at the date of this post.

I’m going to assume it has something to do with my PATH but don’t have a clue what.