B. Jeno
B. Jeno

Reputation: 140

Visual Studio 2017 not detecting change in .cu (CUDA) files

I have Visual Studio 2017 and Cuda Toolkit 9.1 installed. It is working, I confirmed it by building a few projects.

Now when I edit a .cu file and press build. It says that the project is already up to date. It is only possible to build the changes into the new binary, when using rebuild.

Upvotes: 13

Views: 2680

Answers (4)

NvBert
NvBert

Reputation: 11

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

Sorry for the long wait.

Upvotes: 1

Sebastian Wittmeier
Sebastian Wittmeier

Reputation: 11

Microsoft modified the way in VS 2017, how source code changes are detected.

A solution is written from chrispy81 on the Nvidia Developer Forum.

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:

<WriteLinesToFile
    Condition="'%(CudaCompile.ExcludedFromBuild)' != 'true'"
    File="%(CudaCompile.DepsOutputPath)"
    Lines="@(_CudaCompileDeps)"
    Overwrite="true" />

write this:

<PropertyGroup>
    <CudaCompileItemFullPath>%(CudaCompile.FullPath)</CudaCompileItemFullPath>
</PropertyGroup>

<GetOutOfDateItems
    Condition ="'$(SelectedFiles)' == ''"
    Sources ="%(CudaCompile.FullPath);
    @(_CudaCompileDeps)"
    OutputsMetadataName ="Outputs"
    DependenciesMetadataName ="AdditionalInputs"
    CommandMetadataName ="Command"
    TLogDirectory ="$(TLogLocation)"
    TLogNamePrefix ="%(CudaCompile.Filename)%(CudaCompile.Extension)$(CudaCompileItemFullPath.GetHashCode())">
    <Output TaskParameter="OutOfDateSources" ItemName="CudaBuildCoreOutOfDateItems"/>
</GetOutOfDateItems>

Upvotes: 1

Mojca
Mojca

Reputation: 304

After filing a bug report at NVidia, they resolved the ticket in the next working day, promising to deliver the fix with the next release of Nsight Visual Studio. (I'm currenty using Nsight Visual Studio 6.0 which came with CUDA 10.0.)

I'm looking forward to try out the new release (whenever it comes out) and I'm pleasantly surprized by the speed of their response.

Upvotes: 1

Andrew Theiss
Andrew Theiss

Reputation: 61

A work around is to force a Compile instead of a build using Build -> Compile or Ctrl+F7 instead.
This fixed the issue for me, but also please note I initially tried Build -> Run Code Analysis on File (which also worked) before subsequently adopting the aforementioned workaround.

Upvotes: 4

Related Questions