Monday, 3 June 2013

CUDA 5.0 and Visual Studio 2012 installation

I've been experimenting with OpenGL for a while and now I would like to take the next step and check out CUDA. People say amazing things about it and I figured it's about time for me to try it as well. However, the installation process is not as easy as I initially anticipated. After downloading CUDA Toolkit v5.0 and Visual Studio 2012 Express Edition, I found out that these two simply don't like each other and some extra effort had to be invested to get CUDA and VS up and running on my machine. Here's what I had to do:

  • I copied the content of this folder:
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\extras\visual_studio_integration\MSBuildExtensions
    to a safe location (let's say a folder on your desktop). There should be 4 files in total:
    • CUDA 5.0.props
    • CUDA 5.0.targets
    • CUDA 5.0.xml
    • Nvda.Build.CudaTasks.v5.0.dll
    Only first two will be modified but I copied them all to have everything in one place.
  • In my safe folder, I edited the CUDA 5.0.props file and added an extra CudaClVersion node. Was:
    <CudaClVersion Condition="'$(PlatformToolset)' == 'v90'">2008</CudaClVersion> <CudaClVersion Condition="'$(PlatformToolset)' == 'v100'">2010</CudaClVersion>
    <CudaClVersion Condition="'$(PlatformToolset)' == 'v90'">2008</CudaClVersion> <CudaClVersion Condition="'$(PlatformToolset)' == 'v100'">2010</CudaClVersion> <CudaClVersion Condition="'$(PlatformToolset)' == 'v110'">2010</CudaClVersion>
  • Next, in the same folder, I modified the CUDA 5.0.targets file.
    • <CudaCleanDependsOn> node:
    • <CudaCompile> node, GenerateRelocatableDeviceCode attribute:
    • <CudaCompile> node, CodeGeneration attribute:
    • <CudaCompile> node, CommandLineTemplate attribute:
      CommandLineTemplate="&quot;$(CudaToolkitNvccPath)&quot; %(CudaCompile.ApiCommandLineTemplate) %(CudaCompile.CleanCommandLineTemplate)"
      CommandLineTemplate="&quot;$(CudaToolkitNvccPath)&quot; %(CudaCompile.BuildCommandLineTemplate) %(CudaCompile.ApiCommandLineTemplate) %(CudaCompile.CleanCommandLineTemplate)"
  • Next, I copied all 4 files from my safe folder to the MSBuild folder, which I found here:
    C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations
  • Intellisense: to enable CUDA and GLSL code hightlighting I modified following Text Editor settings (can be found under Visual Studio's Tools -> Options menu):

  • I added .cu to the list of included extensions (Tools -> Options -> Projects and Solutions -> VC++ Project Settings)

  • Last step of my preparations was to locate and edit the host_config.h file. It can be found here:
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include
    Line 90 has to be changed from:
    #if _MSC_VER < 1400 || _MSC_VER > 1600
    #if _MSC_VER < 1400 || _MSC_VER > 1700
And that's it. CUDA 5.0 is integrated with Visual Studio 2012. I would like to thank Alan Tatourian for explaining how to do this, please find his blog here if you wish.

No comments:

Post a Comment