转自http://blog.csdn.net/carson2005/article/details/46416859
CUDA是NVIDIA的GPU开发工具,目前在大规模并行计算领域有着广泛应用。
windows平台上面的CUDA开发之前,最好去NVIDIA官网查看说明,然后下载相应的driver, ToolKits等等。如果你下载最新版本的CUDA7.0,里面其实已经包含了driver及Tool kits。
特别要注意:目标最高版本为CUDA7.0,仅支持64位系统(32位没法安装CUDA 7.0 Tool Kits),另外,VS编译平台最低要求是VS2010。 So,那些依然用VC6或者VS2008的就别犹豫了,赶快换平台吧。
下面贴出NVIDIA官网的start guide:(坑爹的NVIDIA,在develop的地方以及下载tool kits的地方,都没有提到这个start guide,造成笔者反复安装配置了多次,奔溃。。。。)
CUDA® is a parallel computing platform and programming model invented by NVIDIA. It enables dramatic increases in computing performance by harnessing the power of the graphics processing unit (GPU).
This guide will show you how to install and check the correct operation of the CUDA development tools.
The next two tables list the currently supported Windows operating systems and compilers.
Operating System | Native x86_64 | Cross (x86_32 on x86_64) |
---|---|---|
Windows 8.1 | YES | YES |
Windows 7 | YES | YES |
Windows Server 2012 R2 | YES | YES |
Windows Server 2008 R2 | YES | YES |
Compiler | IDE | Native x86_64 | Cross (x86_32 on x86_64) |
---|---|---|---|
Visual C++ 12.0 | Visual Studio 2013 | YES | YES |
Visual Studio Community 2013 | YES | NO | |
Visual C++ 11.0 | Visual Studio 2012 | YES | YES |
Visual C++ 10.0 | Visual Studio 2010 | YES | YES |
x86_32 support is limited. See the x86 32-bit Support section for details.
Native development using the CUDA Toolkit on x86_32 is unsupported. Deployment and execution of CUDA applications on x86_32 is still supported, but is limited to use with GeForce GPUs. To create 32-bit CUDA applications, use the cross-development capabilities of the CUDA Toolkit on x86_64.
This document is intended for readers familiar with Microsoft Windows operating systems and the Microsoft Visual Studio environment. You do not need previous experience with CUDA or experience with parallel computation.
To verify that your GPU is CUDA-capable, open the Control Panel ( ) and double click on System. In the System Properties window that opens, click the Hardware tab, then Device Manager. Expand the Display adapters entry. There you will find the vendor name and model of your graphics card. If it is an NVIDIA card that is listed in http://developer.nvidia.com/cuda-gpus, your GPU is CUDA-capable.
The Release Notes for the CUDA Toolkit also contain a list of supported products.
The CUDA Toolkit installs the CUDA driver and tools needed to create, build and run a CUDA application as well as libraries, header files, CUDA samples source code, and other resources.
The download can be verified by comparing the MD5 checksum posted at http://developer.nvidia.com/cuda-downloads/checksums with that of the downloaded file. If either of the checksums differ, the downloaded file is corrupt and needs to be downloaded again.
To calculate the MD5 checksum of the downloaded file, follow the instructions at http://support.microsoft.com/kb/889768.
Before installing the toolkit, you should read the Release Notes, as they provide details on installation and software functionality.
Install the CUDA Software by executing the CUDA installer and following the on-screen prompts.
<PackageName>.exe -s CUDAToolkit_<span class="keyword" style="margin-left: 0px; color: rgb(0, 0, 0);">7.0</span> Display.Driver
Display Driver
Required to run CUDA applications.
CUDA Toolkit
CUDA Visual Studio Integration
The CUDA Visual Studio Integration registers the CUDA plugins with the supported and installed versions of Visual Studio on the system and installs Nsight Visual Studio Edition. This integration allows for CUDA development within Visual Studio.
CUDA Samples
The CUDA Samples contain source code for many example problems and templates with Microsoft Visual Studio 2010, 2012, and 2013 projects.
The CUDA Samples installation defaults to C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.0.
Sometimes it may be desirable to extract or inspect the installable files directly, such as in enterprise deployment, or to browse the files before installation. The full installation package can be extracted using a decompression tool which supports the LZMA compression method, such as 7-zip or WinZip.
Once extracted, the CUDA Toolkit files will be in the CUDAToolkit folder, and similarily for the CUDA Samples and CUDA Visual Studio Integration. Within each directory is a .dll and .nvi file that can be ignored as they are not part of the installable files.
All subpackages can be uninstalled through the Windows Control Panel by using the Programs and Features widget.
On Windows 7 and later, the operating system provides two driver models under which the NVIDIA Driver may operate:
The TCC driver mode provides a number of advantages for CUDA applications on GPUs that support this mode. For example:
TCC is enabled by default on most recent NVIDIA Tesla GPUs. To check which driver mode is in use and/or to switch driver modes, use the nvidia-smi tool that is included with the NVIDIA Driver installation (see nvidia-smi -h for details).
Before continuing, it is important to verify that the CUDA toolkit can find and communicate correctly with the CUDA-capable hardware. To do this, you need to compile and run some of the included sample programs.
The version of the CUDA Toolkit can be checked by running nvcc -V in a Command Prompt window. You can display a Command Prompt window by going to:
Start > All Programs > Accessories > Command Prompt
C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.0\bin\win64\Release
This assumes that you used the default installation directory structure. If CUDA is installed and configured correctly, the output should look similar to Figure 1.
The exact appearance and the output lines might be different on your system. The important outcomes are that a device was found, that the device(s) match what is installed in your system, and that the test passed.
If a CUDA-capable device and the CUDA Driver are installed but deviceQuery reports that no CUDA-capable devices are present, ensure the deivce and driver are properly installed.
Running the bandwidthTest program, located in the same directory as deviceQuery above, ensures that the system and the CUDA-capable device are able to communicate correctly. The output should resemble Figure 2.
The device name (second line) and the bandwidth numbers vary from system to system. The important items are the second line, which confirms a CUDA device was found, and the second-to-last line, which confirms that all necessary tests passed.
If the tests do not pass, make sure you do have a CUDA-capable NVIDIA GPU on your system and make sure it is properly installed.
C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.0\bin\win64\Release
C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.0\<category>\<sample_name>
or the global solution files Samples*.sln located in
C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.0
CUDA Samples are organized according to <category>. Each sample is organized into one of the following folders: (0_Simple, 1_Utilities, 2_Graphics, 3_Imaging, 4_Finance, 5_Simulations, 6_Advanced, 7_CUDALibraries).
The bandwidthTest project is a good sample project to build and run. It is located in the NVIDIA Corporation\CUDA Samples\v7.0\1_Utilities\bandwidthTest directory.
If you elected to use the default installation location, the output is placed in CUDA Samples\v7.0\bin\win64\Release. Build the program using the appropriate solution file and run the executable. If all works correctly, the output should be similar to Figure 2.
The sample projects come in two configurations: debug and release (where release contains no debugging information) and different Visual Studio projects.
A few of the example projects require some additional setup. The simpleD3D9 example requires the system to have a Direct3D SDK (June 2010 or later) installed and the Visual C++ directory paths (located in
) 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 7.0.props file, and is installed automatically as part of the CUDA Toolkit installation process.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations
You can reference this CUDA 7.0.props file when building your own CUDA applications.
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 7.0 Runtime" template will configure your project for use with the CUDA 7.0 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.
While Option 2 will allow your project to automatically use any new CUDA Toolkit version you may install in the future, selecting the toolkit version explicitly as in Option 1 is often better in practice, because if there are new CUDA configuration options added to the build customization rules accompanying the newer toolkit, you would not see those new options using Option 2.
control sysdm.cpl
msbuild <projectname.extension> /t:Rebuild /p:CudaToolkitDir="drive:/path/to/new/toolkit/"
Now that you have CUDA-capable hardware and the NVIDIA CUDA Toolkit installed, you can examine and enjoy the numerous included programs. To begin using CUDA to accelerate the performance of your own applications, consult the CUDA C Programming Guide, located in the CUDA Toolkit documentation directory.
A number of helpful development tools are included in the CUDA Toolkit or are available for download from the NVIDIA Developer Zone to assist you as you develop your CUDA programs, such as NVIDIA® Nsight™ Visual Studio Edition, NVIDIA Visual Profiler, and cuda-memcheck.
For technical support on programming questions, consult and participate in the developer forums at http://developer.nvidia.com/cuda/.