Cuda5.0+vs2008+visualassist Installation
Turn from: http://blog.163.com/qimo601@126/blog/static/15822093201352084242102/
1, software and hardware environment
Operating system: WINDOWS7 Desktop Industrial Control machine
Gpu:geforce GT420 (graphics card for another desktop in the office)
Development environment: VisualStudio2008, Cuda_5.0.35_winvista_win7_win8_general_32-3, va_x_setup1845
2, software preparation
CUDA official website Https://developer.nvidia.com/cuda-downloads
CUDA5.0 installation package Download (CUDA5.0 already integrated, graphics driver, CUDA ToolKit, CUDA SDK code example)
va_x_setup1845 Download
3. Installation process
3.1 Install VS2008 First, then install Visualassist X
VA is intended to facilitate program writing and is not required to be installed.
3.2 CUDA5.0 Installer installation process
Direct default installation, automatic installation of CUDA Toolkit, CUDA SDK code samples, and developer-driven.
Cudatoolkit default installation directory: C:\Program files\nvidia GPU Computing toolkit\cuda\v5.0
Default installation directory for the CUDA SDK: C:\ProgramData\NVIDIA corporation\cuda samples\v5.0
3.3 Configuring environment variables
The system environment variables are configured automatically after the Toolkit and SDK have been installed. You can view the system environment variables and find that the following variables are automatically created:
Cuda_path= C:\Program Files\nvidia GPU Computing toolkit\cuda\v5.0\
Cuda_path_v5_0= C:\Program Files\nvidia GPU Computing toolkit\cuda\v5.0\
Nvcudasamples_root= C:\ProgramData\NVIDIA Corporation\cuda samples\v5.0\
Nvcudasamples5_0_root= C:\ProgramData\NVIDIA Corporation\cuda samples\v5.0\
Nvtoolsext_path= C:\Program Files\nvidia GPU Computing toolkit\nvtoolsext\
Path= C:\Program Files\nvidia GPU Computing toolkit\cuda\v5.0\bin\; C:\Program Files\nvidia GPU Computing toolkit\cuda\v5.0\libnvvp\; C:\Program Files\nvidia Corporation\physx\common; C:\Program Files\intel\icls client\;%systemroot%\system32;%systemroot%;%systemroot%\system32\wbem;%systemroot%\ System32\windowspowershell\v1.0\; C:\Program Files\intel\opencl sdk\2.0\bin\x86; C:\Program Files\intel\intel (R) Management Engine components\dal; C:\Program Files\intel\intel (R) Management Engine components\ipt;c:\program Files\Microsoft SQL Server\90\tools\binn\ ; C:\Qt\4.7.4\bin
Run Cuda from the instance with the following error
3.4 Reboot the computer, the above problem will not be wrong
Set up a Cuda test project on the VS2008
Compilation Successful!
4 CUDA/C + + keywords and function highlighting 4.1. C + + keyword highlighting in the. cu fileThis setting is for visual Studio2008 to highlight the C + + syntax in the. cu file when editing the. cu file. Set the method: In the Visual Studio 2008 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 2008, 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 settingIn order to make CUDA keywords, such as __device__, dim3 text highlighting, you need to set the following steps: C:\ProgramData\NVIDIA Corporation\cuda Samples\v5.0\doc\syntax_hi Usertype.dat files in the Ghlighting\visual_studio_8 directory are copied to the C:\Program Files\Microsoft Visual Studio9.0\common7\ide\ directory (for x64 Bit Win7 system for X:\Program Files (X86) \microsoft Visual Studio 9.0\common7\ide\). "Of course I have the QT project on this machine, so I merged the old and new usertype.dat files directly." "When you open the. cu file after you restart Visual Studio 2008, the CUDA keyword should turn blue."
4.3 CUDA function highlighting, and CUDA function input code hintImplementing this functionality requires the use of visual Assist X, which cannot be achieved without installing visual Assist X, which supports visual Studio 2008. 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 completionIn the visual Studio 2008 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 Corp. Oration\cuda Samples\v5.0\common\inc
2 Enable Visual Assistx support. cu fileEnables 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 2008 first to avoid unnecessary errors. Using the Win+r key to open the Run window, type in the regedit command (abbreviation for register Edit) to open the registry and find the following location: Hkey_current_user\software\whole tomato\visual Assist X\vanet9. 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 2008,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.
Reference: 1, CUDA5.0 + Visual Studio 2010 Environment Configuration 2, Cuda installation 3, CUDA installation
Note: The CUDA Project test code #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include &L T;time.h> cudaerror_t Addwithcuda (int*c,Constint*a,Constint*b,size_tsize); __global__voidAddkernel (int*c,Constint*a,Constint*B) {inti = threadidx.x + blockidx.x * griddim.x; C[i] = A[i] + b[i] + c[i];