Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Visual Studio: Adding CUDA Build Rule

📅 2011-Jan-31 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ build rules, cuda, visual studio ⬩ 📚 Archive

To compile CUDA source files (*.cu) in Visual Studio, a custom build rule is necessary. The following CUDA build rules are provided by NVIDIA:

All these build rule files are installed into the C:\Program Files\Microsoft Visual Studio 9.0\VC\VCProjectDefaults directory by the CUDA Toolkit or the GPU Computing SDK. In Visual Studio language, this is the $(VCInstallDir)\VCProjectDefaults directory.

To add a CUDA build rule, right-click on the Project name in the Solution Explorer pane and choose Custom Build Rules. The above build rules should be visible in the Visual C++ Custom Build Rules Files dialog that pops up. Choose the build rule you want and compile the CUDA files.

Note: It is recommended to choose NvCudaRuntimeApi.rules or NvCudaDriverApi.rules over the generic Cuda.rules.

Tried with: CUDA 3.2 and Visual Studio 2008.

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧