Compiling CUDA Programs
www.nvidia.com
NVIDIA CUDA Getting Started Guide for Microsoft
Windows
DU-05349-001_v6.5|10
C++ directory paths (located in Tools > Options...) properly configured. Consult the
Direct3D documentation for additional details.
These sample projects also make use of the $CUDA_PATH environment variable to locate
where the CUDA Toolkit and the associated .props files are.
The environment variable is set automatically using the Build Customization CUDA
6.5.props file, and is installed automatically as part of the CUDA Toolkit installation
process.
For Visual Studio 2010, the CUDA 6.5.props file is installed into:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V100\BuildCustomizations
For Visual Studio 2012, the CUDA 6.5.props file is installed into:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations
For Visual Studio 2013, the CUDA 6.5.props file is installed into:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations
You can reference this CUDA 6.5.props file when building your own CUDA
applications.
3.3.Build Customizations for New Projects
When creating a new CUDA application, the Visual Studio project file must be
configured to include CUDA build customizations. To accomplish this, click File-> New
| Project... NVIDIA-> CUDA->, then select a template for your CUDA Toolkit version.
For example, selecting the "CUDA 6.5 Runtime" template will configure your project for
use with the CUDA 6.5 Toolkit. The new project is technically a C++ project (.vcxproj)
that is preconfigured to use NVIDIA's Build Customizations. All standard capabilities of
Visual Studio C++ projects will be available.
To specify a custom CUDA Toolkit location, under CUDA C/C++, select Common, and
set the CUDA Toolkit Custom Dir field as desired. Note that the selected toolkit must
match the version of the Build Customizations.
3.4.Build Customizations for Existing Projects
When adding CUDA acceleration to existing applications, the relevant Visual Studio
project files must be updated to include CUDA build customizations. This can be done
using one of the following two methods:
1.
Open the Visual Studio project, right click on the project name, and select Build
Customizations..., then select the CUDA Toolkit version you would like to target.
2. Alternatively, you can configure your project always to build with the most recently
installed version of the CUDA Toolkit. First add a CUDA build customization to
your project as above. Then, right click on the project name and select Properties.
Under CUDA C/C++, select Common, and set the CUDA Toolkit Custom Dir field
to $(CUDA_PATH) . Note that the $(CUDA_PATH) environment variable is set by the
installer.