Environment configuration for CUDA5.0 + Visual Studio 2010

Source: Internet
Author: User
Tags win32 cuda toolkit visual studio 2010

According to the previous written cuda4.0 configuration, I configured a bit of cuda5.0, the configuration process has some differences, after some debugging success. So summed up the configuration of Cuda5.0, to give you a reference to it.

1 Installation Environment operating system:

Win8 32-bit Professional Edition

Graphics card model: NVIDIA gtx650ti

2 Software Preparation
(1) Microsoft Visual Studio 2010

(2) Visual Assist X

(3) graphics driver, CUDA Toolki,cuda SDK v4.0 5.0 has integrated these three:

Desktop version: http://developer.download.nvidia.com/compute/cuda/5_0/rel-update-1/installers/cuda_5.0.35_
Winvista_win7_win8_general_32-1.msi

Notebook version: Http://developer.download.nvidia.com/compute/cuda/5_0/rel-update-1/installers/cuda_5.0.35_
Winvista_win7_win8_notebook_32-1.msi

3 Installation Steps

3.1 Visual Studio 2010 and visual Assist X installation

Install Visual Studio 2010 before installing the assistant Visual Assist X. Visual Assist X Here is not necessary for parallel computations using CUDA, but for the convenience of programming, installation is recommended here.

3.2 Installation Cuda5.0

The default installation directory for the CUDA Toolkit is: C:\Program files\nvidia GPU Computing toolkit\cuda\v5.0 CUDA The default installation directory for the SDK is: C:\ProgramData\NVIDIA Co Rporation\cuda samples\v5.0
3.3 Configuring environment variables

The system environment variables are configured automatically after the Toolkit and SDK have been installed. For insurance purposes, configure the environment variables manually. Create the following item in the System environment variable:
Cuda_sdk_path = C:\ProgramData\NVIDIA Corporation\cuda Samples\v5.0\common

Cuda_path = C:\Program Files\nvidia GPU Computing toolkit\cuda\v5.0

Cuda_lib_path =%cuda_path%\lib\win32

Cuda_bin_path =%cuda_path%\bin

Cuda_sdk_lib_path =%cuda_sdk_path%\common\lib\win32

Cuda_sdk_bin_path =%cuda_sdk_path%\bin\win32

After the system environment variable Path, add the following:;%cuda_lib_path%;%cuda_bin_path%;%cuda_sdk_lib_path%;%cud a_sdk_bin_path%;

4 CUDA/C + + keywords and function highlighting

4.1. C + + keyword highlighting in the. cu file

This setting is for visual Studio2010 to highlight the C + + syntax in the. cu file when editing the. cu file. Set the method: in the Visual Studio 2010 menu, select tools| options| Text editor| File Extension (Tools | options | Text Editor | file extension), in this window, select Microsoft Visual C + + in the Editor drop-down box, and enter a CU click in the Extension (extension) text box. Add button, repeat the work to add cuh to the Visual C + + type, and click the OK button when you add it, as shown in Figure 1.


After you restart Visual Studio 2010, the. cu file C + + keyword is highlighted. However, at this point the CUDA keyword is still black, the next step to Cuda key from the highlighted.

4.2 CUDA keyword Highlight setting

In order to make Cuda keywords, such as __device__, DIM3, and other text highlighting, you need to set the following steps:

The usertype.dat in the Samples\v5.0\doc\syntax_highlighting\visual_studio_8 directory of C:\ProgramData\NVIDIA Corporation\cuda File copied to C:\Program Files\Microsoft Visual Studio10.0\common7\ide\ Directory

When you restart Visual Studio 2010 and open the. cu file, the CUDA keyword should turn blue.

4.3 CUDA function highlighting, and CUDA function input code hint

Implementing this functionality requires the use of visual Assist X, which cannot be achieved without installing visual Assist X, which supports visual Studio 2010. This is just to make coding more convenient, there is no real obstacle to the development of CUDA programs.
If you have installed visual Assist X, you can implement the required functionality in the following two steps.
1 Enable visual Assist X to support Cuda function highlighting and code completion
In the Visual Studio 2010 menu, select: "Vassistx| Visual Assist X options| projects| C/c++directories, select Custom in the "Platform" drop-down box of the interface, select other include files in the show directories for Drop-down box, and then in the following input box, create a new, Add the following path, as shown in Figure 2:

C:\Program Files\nvidia GPU Computing toolkit\cuda\v5.0\include

C:\ProgramData\NVIDIA Corporation\cuda Samples\v5.0\common\inc


2 Enable visual Assistx support. cu file

Enables visual Assist X to implement the. cu file highlighting and code completion function, which requires editing the registry. When you modify the registry, turn off Visual Studio 2010 first to avoid unnecessary errors. Use the WIN+R key combination to open the Run window and type in the regedit command (abbreviation for register edit)

Open the registry and find the following location: Hkey_current_user\software\whole tomato\visual Assist x\vanet10.

On the right to find the Extsource item, the right mouse button selected changes, in the original text after adding the following text:. cu;. Cuh; Close the registry when you are sure.

Re-opening Visual Studio 2010,visual Assist X begins to support the syntax highlighting and code completion of the CU and. cuh files.

At this point, the Cuda function of the. cu file is highlighted, and the function name symbol automatically prompts the full name of the function, the parameter type, and so on.

5 Creating the Project

5.1 Create Cuda Project

In the Visual Studio 2010 menu, select File|new|project (file | new | project) to select the "Installed Templates" column in the Open New Project window nvidia| CUDA ", the type selected as" CUDA 5.0 Runtime ", see the figure below.



After you enter the project name in name, click OK. The KERNEL.CU sample provided by the system can be compiled and run with the results shown below.



Finally, to illustrate that this version of the CUDA does not support the Cutil.h file, I currently put the macro delete this H file and then run. Written in English: Prior to CUDA 5.0, CUDA Sample projects referenced a utility library with header and source files called Cutil. This is has been removed with the CUDA's Samples in CUDA 5.0, and replaced with header files found in CUDA Inc helper_cuda.h, Helper_cuda_gl.h, helper_cuda_drvapi.h, Helper_functions.h, Helper_image.h, HELPER_MATH.H, Helper_ String.h, and Helper_timer.h.these files provide utility functions for CUDA device initialization, CUDA error checking, St  Ring parsing, image file loading and saving, and timing functions. The CUDA Samples projects no longer have references and dependencies to Cutil, and would now use the helper functions Goi Ng forward.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.