top of page

Adding CUDA capabilities to an existing C++ Visual Studio project

  • Writer: Shaveen Kumar
    Shaveen Kumar
  • May 4, 2017
  • 1 min read

At the time of writing this, the latest version of CUDA is 8.0 and can be downloaded here:

The version of Visual Studio I'm using is 2015.

The easiest way to get started with a CUDA project in Visual Studio is to create a new project and choose CUDA as the project type. But if you already had an existing project and would not like to start over with a new project, here is how you do it.

First step is to copy all files present in:

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\extras\visual_studio_integration\MSBuildExtensions

(or wherever your NVIDIA GPU Computing Toolkit directory is) into:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\VCProjectDefaults

Next, go to your existing C++ project (or as an example, create a new "Empty C++ project")

After the project has been opened, right click the project in the Solution Explorer and choose Build Dependencies->Build Customizations...

Here you will now be able to see a CUDA configuration to choose. Make sure you select it.

Almost there. The final step is to go to your project properties page by right clicking on the project like before and then choosing Properties. Here you need to configure the Linker to also include the cuda library, so under Configuration Properties -> Linker -> Input, add the value cudart.lib.

That's it! Now try adding a CUDA file to your Source Files directory by right clicking and adding a new file with an extension .cu. For starters, you can try the free kernel.cu file that is created by default when you create a new CUDA Runtime project. Congratulations you just added CUDA capabilities to your existing C++ project in Visual Studio!

bottom of page