Visual Studio 2017 not detecting changes in CUDA .cu files

I think this is caused by a change in VS 2017:

“…as VC build Up-To-Date check solely relies on read and write tlog files created during build and not checking project items any more.”

Microsoft says they changed the up-to-date check in VS 2017, so it is up to Nvidia to change their CUDA integration:

Yes, its being worked on internally as a result of the bug filed that was mentioned in one of the previous comments in this thread.

Thanks Robert. I tried to adjust the custom CUDA 10.0.targets but could not get it to work.

My rant to Microsoft is included (from Visual Studio Feedback):

"While Olga’s “suggestion” is obviously correct, the required action is next to impossible!
There is very little documentation on this vital change. So if one takes the CUDA 10.0.targets (from the CUDA 10.0 toolkit) it is 928 lines long and I have no guidance on where to make the change.

My frustration is with the approach here.

  1. This was a BREAKING change.
    ​2. It was not communicated in advance
    ​3. The documentation is inadequate for this change
    ​4. This was not communicated to partners like NVIDIA
    ​5. Microsoft considers that this is unimportant for those outside the organization.

This was a huge impact on productivity. With 50 CUDA kernels, we went from having to compile 1 to ALWAYS having to compile all.

END OF RANT"

@Robert_Crovella

Any info about the ETA of the fix. We badly need an improved MSBuild integration.

Does someone have a workaround with GetOutOfDateItems mentioned here?
[url]Visual Studio Feedback

Edit: Not working correctly! See improved solution later.

I managed to find a workaround:

In the CUDA 10.0.targets files:
“C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\BuildCustomizations\CUDA 10.0.targets”
“C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations\CUDA 10.0.targets”
“c:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\extras\visual_studio_integration\MSBuildExtensions\CUDA 10.0.targets”

under this tag:

write this:



Hope this helps!

Can confirm the above solution works. For me, I only had the first file and it was enough. Cheers!

Hi chrispy81,

Thanks for sharing the information. This works okay for us too, although it seems to somehow require some weird sequence of actions before it’s effective for all .cu files in a project. As if one “previous” failure per .cu file is required before it starts working.

Cheers!

Hi ghoogewerf,

Yes the previous solution only worked for a single .cu file. I improved it and it works for multiple files, and their dependencies as well.

In the CUDA 10.0.targets files:
“C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\BuildCustomizations\CUDA 10.0.targets”
“C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations\CUDA 10.0.targets”
“c:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\extras\visual_studio_integration\MSBuildExtensions\CUDA 10.0.targets”

under this tag:

write this:

%(CudaCompile.FullPath)



Hi chrispy81,

Thanks for the information. This seems to eliminate the problem.

Cheers,

It seems CUDA 10.1 fixed this in the CUDA 10.1.targets file. It can be backported to CUDA 10.0.targets easily by changing 10.1 to 10.1 everywhere.

@Robert_Crovella
Can you confirm, that #2396234 has been fixed? Thanks.

@Robert_Crovella

I can confirm that #2396234 appears to be fixed in CUDA 10.1.

Good News!
This problem has been addressed and is available with the CUDA 10.1 Toolkit, released in February 2019.
[url]https://developer.nvidia.com/cuda-toolkit[/url]

Sorry for the long wait.

Ref:2396234

I still doesn’t work for me for CUDA 10.1 Update 1.
Workaround by chrispy81 works (VS2017 + CMake 3.15).

I can confirm this is NOT FIXED in the latest CUDA 10.1 release.

The workaround by Chrispy81 is required to make it work.

Why is this not fixed? This is embarassing NVIDIA. This completely breaks VS2017 usability w/ CUDA.

This didn’t work for me. When I do this for all 3 files and open a CUDA project in VS2017, .cu file doesn’t appear on the solution explorer and I get the following error as soon as VS2017 is opened:

error : Designtime build failed for project 'path_to_project.vcxproj' configuration 'Debug|x64'. IntelliSense might be unavailable.

Set environment variable TRACEDESIGNTIME = true and restart Visual Studio to investigate.

Any help?

Same problem in VS2019 with Cuda 11.3.1.
Codes disappeared in @chrispy81 's reply. Could someone help recall the solution again?

PS: found in Visual Studio 2017 not detecting change in .cu (CUDA) files - Stack Overflow

But it doesn’t work for VS 2019.

I managed to solve this editing the .targets file installed by NVIDIA, but now VS is not able to add any dependencies of the .cu (includes) to the tlog files, so if I change any .cu header, I need to force rebuild all my .cu files, which is quite time consuming.