Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 322
B. Jeno Avatar asked Jan 10 '18 09:01

B. Jeno


3 Answers

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.

like image 174
Mojca Avatar answered Dec 02 '22 03:12

Mojca


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>
like image 29
Sebastian Wittmeier Avatar answered Dec 02 '22 04:12

Sebastian Wittmeier


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.

like image 37
Andrew Theiss Avatar answered Dec 02 '22 04:12

Andrew Theiss