Checking CUDA installation in MS Visual Studio 2015

Home and Applets > Download SVD-GPU Application Source Code > Checking CUDA Installation in MS Visual Studio 2015

Your computer has a CUDA enabled Nvidia graphic processing unit (GPU). Ensure you have Microsoft Visual Studio installed before you install the CUDA toolkit. Not doing so will result in Visual Studio integration not functioning. Visual Studio Community edition was announced on 12 November 2014, as a new free version, with similar functionality to Visual Studio Professional (Visual Studio 2015 = Visual Studio 14).
Three projects (deviceQuery.cpp, bandwidthTest.cu, and Mandelbrot.cu) are presented for checking the installation of CUDA in MS Visual Studio 2015.

*** Outline ***

  1. Installation of MS Visual Studio 2015 and Nvidia CUDA toolkit
  2. Installation checking with deviceQuery
  3. deviceQuery.cpp project
  4. bandwidthTest.cu project
  5. Mandelbrot.cu project
  6. References

Installation of MS Visual Studio 2015 and Nvidia CUDA toolkit

CUDA / Microsoft Visual C++ compatibility: In Windows, the NVIDIA CUDA compiler nvcc uses a Visual C/C++ compiler behind the scenes.

  1. Install Visual Studio Community 2015 with update 3, x64 (Release date: 27/Jun/2016)
  2. Install the lastest NVIDIA Driver. You need to ensure that your driver version matches or exceeds your CUDA Toolkit version.

  3. Install CUDA toolkit 8.0 GA1 (sept 2016) with local installer, which is a stand-alone installer with a large initial download.

Folder locations:

(1) CUDA SDK:

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

Its include folder contains the cuda_xx.h files of CUDA.

(2) CUDA Samples:

C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\common

Its inc folder contains the xx.h files.

(3) My Visual Studio 2015 project folder:

C:\Users\Papa\Documents\Visual Studio 2015\Projects

Installation checking with deviceQuery

The best way to check your computer environment is to run an existing Nvidia sample project: deviceQuery.

  1. Copy the folder C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\1_Utilities\deviceQuery into the Projects folder C:\Users\Papa\Documents\Visual Studio 2015\Projects
  2. Launch Visual Studio.

    In Start Page, select Open Project...
  3. Open deviceQuery_vs2015.sln of project folder.
    Click deviceQuery.cpp file in Solution Explorer to open it.

    The word include before < helper_cuda.h> is wave-underlined in red.
    The Solution Platform x64 is shown near Debug.
  4. Right click the project name deviceQuery in Solution Explorer, then select Properties.
    The panel of deviceQuery Property Pages appears.
    Under Configuration Properties, select VC++ Directories.
    Add an extra ; at the end of Include Directories, then add C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\common\inc

    Click the mouse so that Appliquer button becomes active. Click Appliquer button then OK button.
  5. The red wave line under #include has disappeared.

  6. Select Build menu then Build Solution.

    Five files (deviceQuery.exe, deviceQuery.lib, deviceQuery.exp, deviceQuery.ilk, and deviceQuery.pdb) are generated in the folder C:\Users\Papa\Documents\Visual Studio 2015\bin\win64\Debug.
  7. Select Debug menu then Start Without Debugging.

deviceQuery.cpp project

Create your own deviceQuery project.

  1. In Start Page, click New Project...

  2. Select Win32 Console Application.
    Provid the name of the project: ConsoleApplication-deviceQuery

    Click OK button.
  3. Welcome to the Win32 Application Wizard panel appears.

    Click Next > button.
  4. Application Settings panel appears.

    Ensure to select Empty project and click Finish button.
  5. The Visual Studio editor appears.

    Right-click the folder of Source Files in Solution Explorer. Select Add then New Item...
  6. The default choice is C++ File (.cpp).
    Provid the name of the file: Test-deviceQuery.cpp

    Click Add button.
  7. An empty source file appears for editing.

  8. Copy and paste the file C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\1_Utilities\deviceQuery\deviceQuery.cpp into the empty source file.

    Many words are wavy-underlined in red.
  9. Select x64 platform.

  10. Right-click the file Test-deviceQuery.cpp in Solution Explorer. Select Properties.
    The panel of Test-deviceQuery.cpp property Pages appears.

    The Item Type is C/C++ compiler. Close the panel.
  11. Right-click the project ConsoleAplication-deviceQuery in Solution Explorer.
    Choose Build Dependencies then Build Customizations...
    The Visual C++ Build Customizations Files dialog appears.

    Tick CUDA 8.0(.targets, .props). As a result, VC++ knows that CUDA C/C++ is required.
  12. Right click the project ConsoleAplication-deviceQuery in Solution Explorer. Select Properties.
    Select CUDA C/C++ then Common.

    Choose 64-bit (--machine 64) for Target Machine Platform.
    Click Appliquer button then OK button.
  13. The word include before <cuda_runtime.h> and others are not wavy-underlined.

  14. Right click the project ConsoleAplication-deviceQuery in Solution Explorer. Select Properties.
    Select VC++ Directories.
    Add C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\common\inc in Include Directories.

    Click Appliquer button then OK button.
  15. The word include before <helper_cuda.h> is not wavy-underlined.

  16. Select Build menu then Build Solution.

    Error List appears.
  17. Right click the project ConsoleAplication-deviceQuery in Solution Explorer. Select Properties.
    Click Linker, then Input.
    Add cudart_static.lib; in Additional Dependencies.

    Click Appliquer button then OK button.
  18. Select Build menu then Rebuild Solution.

    Five files (ConsoleApplication-deviceQuery.exe, ConsoleApplication-deviceQuery.lib, ConsoleApplication-deviceQuery.exp, ConsoleApplication-deviceQuery.ilk, and ConsoleApplication-deviceQuery.pdb) are generated. This time, they are located in the folder C:\Users\Papa\Documents\Visual Studio 2015\Projects\ConsoleApplication-deviceQuery\x64\Debug.
  19. Select Debug menu then Start Without Debugging.

bandwidthTest.cu project

Create your our bandwidthTest project.

  1. In Start Page, select New Project...
  2. Select Win32 Console Application. Provid the name of the project: ConsoleApplication-bandwidthTest.

    Click OK button.
  3. Welcome to the Win32 Application Wizard panel appears. Click Next > button.
  4. Application Settings panel appears. Select Empty project then click Finish button.
  5. The Visual Studio editor appears. Right click the folder of Source Files in Solution Explorer for adding a new item. Select Add then New Item...
  6. Provid the name of Visual C++ File(.cpp): test-bandwidthTest.cu.

    The file extension is .cu instead of .cpp. Click Add button.
    The file extension is important. VC++ knows that this is a CUDA source file, which must be compiled with nvcc.
  7. An empty source file appears for editing.
  8. Copy and paste the file C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\1_Utilities\bandwidthTest\bandwidthTest.cu into the empty source file.

    Sevral include words are wave-underlined in red.
  9. Select x64 platform.
  10. Right click the file test-bandwidthTest.cu in Solution Explorer. Select Properties.

    Check that the Item Type is Does not participate in build. The choice box does not contain CUDA C/C++. Close the panel.
  11. Right click the project ConsoleAplication-bandwidthTest in Solution Explorer. Select Build Dependencies then Build Customizations...

    Tick CUDA 8.0(.targets, .props).
  12. Right click again the file test-bandwidthTest.cu in Solution Explorer. Select Properties.

    This time, the choice box contains CUDA C/C++. Select CUDA C/C++.

  13. Click the mouse so that Appliquer button becomes active. Click Appliquer button then OK button.
  14. Right click the project ConsoleAplication-bandwidthTest in Solution Explorer. Select Properties, CUDA C/C++, and Common. Choose 64-bit (--machine 64) for Target Machine Platform. Click Appliquer button then OK button.
  15. The word include before <cuda_runtime.h> and that before <cuda.h> are not wave-underlined.

  16. Right click the project ConsoleAplication-bandwidthTest in Solution Explorer. Select Properties, then VC++ Directories. Add C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\common\inc in Include Directories. Click Appliquer button then OK button.
  17. The word include before <helper_functions.h> and that before before <helper_cuda.h> are not wave-underlined.
  18. Right click the project ConsoleAplication-bandwidthTest in Solution Explorer. Select Properties, Linker, and Input. Add cudart_static.lib; in Additional Dependencies. Click Appliquer button then OK button.
  19. Select Build menu then Rebuild Solution.
  20. Select Debug menu then Start Without Debugging

Mandelbrot.cu project

Create your Mandelbrot project.

  1. In Start Page - Microsoft Visual Studio, select New Project...
  2. Select Win32 Console Application. Provid the name of the project: ConsoleApplication1-Mandelbrot. Click OK button.
  3. Welcome to the Win32 Application Wizard panel appears. Click Next > button.
  4. Application Settings panel appears. Tick Empty project then click Finish button.
  5. The Visual Studio editor appears.

    *****************
  6. Right click the folder of Source Files in Solution Explorer for adding a new item. Select Add then New Item...
  7. Provid the name of C++ File(.cpp): Mandelbrot_cuda.cu.
    The file extension is .cu instead of .cpp. Click Add button.
    The file extension is important. VC++ knows that this is a CUDA source file, which must be compiled with nvcc.
  8. An empty source file appears for editing.
  9. Copy and paste the file C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\2_Graphics\Mandelbrot\Mandelbrot_cuda.cu into the empty source file.

    *****************
  10. Right click the folder of Source Files in Solution Explorer for adding a new item. Select Add then New Item...
  11. Provid the name of C++ File(.cpp): Mandelbrot.cpp.
    Click Add button.
  12. An empty source file appears for editing.
  13. Copy and paste the file C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\2_Graphics\Mandelbrot\Mandelbrot.cpp into the empty source file.

    *****************
  14. Right click the folder of Source Files in Solution Explorer for adding a new item. Select Add then New Item...
  15. Provid the name of C++ File(.cpp): Mandelbrot_gold.cpp.
    Click Add button.
  16. An empty source file appears for editing.
  17. Copy and paste the file C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\2_Graphics\Mandelbrot\Mandelbrot_gold.cpp into the empty source file.

    *****************
  18. Right click the folder of Source Files in Solution Explorer for adding a new item. Select Add then New Item...
  19. Provid the name of C++ File(.cpp): Mandelbrot_kernel.cuh.
    The file extension is .cuh. Click Add button.
  20. An empty source file appears for editing.
  21. Copy and paste the file C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\2_Graphics\Mandelbrot\Mandelbrot_kernel.cuh into the empty source file.

    *****************
  22. Right click the folder of Header Files in Solution Explorer for adding a new item. Select Add then New Item...
  23. Select Header File(.h).
    Provid the name of Header File(.h): Mandelbrot_gold.h.
    The file extension is .h. Click Add button.
  24. An empty source file appears for editing.
  25. Copy and paste the file C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\2_Graphics\Mandelbrot\Mandelbrot_gold.h into the empty source file.

    *****************
  26. Right click the folder of Header Files in Solution Explorer for adding a new item. Select Add then New Item...
  27. Select Header File(.h).
    Provid the name of Header File(.h): Mandelbrot_kernel.h.
    Click Add button.
  28. An empty source file appears for editing.
  29. Copy and paste the file C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\2_Graphics\Mandelbrot\Mandelbrot_kernel.h into the empty source file.

    *****************

  30. Select x64 platform.

  31. Right click the project ConsoleApplication1-Mandelbrot in Solution Explorer. Select Build Dependencies then Build Customizations...

    Tick CUDA 8.0(.targets, .props). Click OK button.

    *****************
  32. Right click the file Mandelbrot_kernel.cuh in Solution Explorer. Select Properties.
    The Item Type is Does not participate in build. Close the panel.

    *****************
  33. Right click the file Mandelbrot_cuda.cu in Solution Explorer. Select Properties.
    Select CUDA C/C++ for Item Type. Click Appliquer button.

  34. Select CUDA C/C++ then Common. Choose 64-bit (--machine 64) for Target Machine Platform.

    Click Appliquer button then OK button.

    *****************
  35. Right click the file Mandelbrot.cpp in Solution Explorer. Select Properties.
    The Item Type is C/C++ compiler. Close the panel.

    *****************
  36. Right click the file Mandelbrot_gold.cpp in Solution Explorer. Select Properties.
    The Item Type is C/C++ compiler. Close the panel.

    *****************
  37. Right click the file Mandelbrot_gold.h in Solution Explorer. Select Properties.
    The Item Type is C/C++ header. Close the panel.

    *****************
  38. Right click the file Mandelbrot_kernel.h in Solution Explorer. Select Properties.
    The Item Type is C/C++ header. Close the panel.

    *****************
  39. Right click the project ConsoleAplication1-Mandelbrot in Solution Explorer. Select Properties, then VC++ Directories.
    Add C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\common\inc; in Include Directories. It contains some XXX.h files.
    Add C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\common\lib\x64; in Library Directories. It contains glew64.lib.

    Click Appliquer button then OK button.
  40. Right click the project ConsoleAplication1-Mandelbrot in Solution Explorer. Select Properties, Linker, and Input.
    Add cudart_static.lib; glew64.lib; in Additional Dependencies.

    Click the mouse for activing Appliquer button. Click Appliquer button then OK button.
  41. Right click the project ConsoleAplication1-Mandelbrot in Solution Explorer. Select Properties, CUDA C/C++, and Common. Choose 64-bit (--machine 64) for Target Machine Platform.

    Click Appliquer button then OK button.
  42. Select Build menu then Build Solution. A message panel appears.

    Tick Apply to all documents. Click Yes button.

  43. Five files (ConsoleApplication1-Mandelbrot.exe, ConsoleApplication1-Mandelbrot.lib, ConsoleApplication1-Mandelbrot.exp, ConsoleApplication1-Mandelbrot.ilk, and ConsoleApplication1-Mandelbrot.pdb) are generated in the folder C:\Users\Papa\Documents\Visual Studio 2015\Projects\ConsoleApplication1-Mandelbrot\x64\Debug.
  44. Copy and paste the two files glew64.dll and freeglut.dll from the folder C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\extras\demo_suite into the folder C:\Users\Papa\Documents\Visual Studio 2015\Projects\ConsoleApplication1-Mandelbrot\x64\Debug, the folder containing ConsoleApplication1-Mandelbrot.exe.
  45. Select Debug menu then Start Without Debugging

References

  1. Augustin: Getting started with Visual Studio for C and C++ development
  2. Nilton Cesar Rojas Vales: Install CUDA on Windows: The definitive guide
  3. Microsoft: VC++ directories property page (Windows)
  4. Microsoft: Create a C++ console app project
  5. 欧新宇: Cuda-convnet配置指南 on Windows8.1+CUDA6.5+VS2013
  6. Developpez: Une introduction à CUDA
  7. Techspot: Nvidia Quadro Graphics ODE Driver 412.16 for Windows 10 64-bit

Solid-state NMR bibliography for:

Aluminum-27
Antimony-121/123
Arsenic-75
Barium-135/137
Beryllium-9
Bismuth-209
Boron-11
Bromine-79/81
Calcium-43
Cesium-133
Chlorine-35/37
Chromium-53
Cobalt-59
Copper-63/65
Deuterium-2
Gallium-69/71
Germanium-73
Gold-197
Hafnium-177/179
Indium-113/115
Iodine-127
Iridium-191/193
Krypton-83
Lanthanum-139
Lithium-7
Magnesium-25
Manganese-55
Mercury-201
Molybdenum-95/97
Neon-21
Nickel-61
Niobium-93
Nitrogen-14
Osmium-189
Oxygen-17
Palladium-105
Potassium-39/41
Rhenium-185/187
Rubidium-85/87
Ruthenium-99/101
Scandium-45
Sodium-23
Strontium-87
Sulfur-33
Tantalum-181
Titanium-47/49
Vanadium-51
Xenon-131
Zinc-67
Zirconium-91
[Contact me] - Last updated August 26, 2022
Copyright © 2002-2024 pascal-man.com. All rights reserved.