如何使用CUDA 顯卡編程


第一步  先確定你的顯卡 是不是N卡(控制面板     》系統》設備管理器》顯示適配器)

第二步    查看你的顯卡 在不在 支持的顯卡 行列   https://developer.nvidia.com/cuda-gpus點擊打開鏈接
第三步   安裝( windows電腦中 須是 vs2008   vs2005)

CUDA Development Tools   https://developer.nvidia.com/cuda-downloads點擊打開鏈接




NVIDIA CUDA Getting Started Guide for Microsoft Windows

Introduction

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).

CUDA was developed with several design goals in mind:
  • Provide a small set of extensions to standard programming languages, like C, that enable a straightforward implementation of parallel algorithms. With CUDA C/C++, programmers can focus on the task of parallelization of the algorithms rather than spending time on their implementation.
  • Support heterogeneous computation where applications use both the CPU and GPU. Serial portions of applications are run on the CPU, and parallel portions are offloaded to the GPU. As such, CUDA can be incrementally applied to existing applications. The CPU and GPU are treated as separate devices that have their own memory spaces. This configuration also allows simultaneous computation on the CPU and GPU without contention for memory resources.
CUDA-capable GPUs have hundreds of cores that can collectively run thousands of computing threads. These cores have shared resources including a register file and a shared memory. The on-chip shared memory allows parallel tasks running on these cores to share data without sending it over the system memory bus.

This guide will show you how to install and check the correct operation of the CUDA development tools.

System Requirements

To use CUDA on your system, you will need the following:
  • CUDA-capable GPU
  • Microsoft Windows XP, Vista, 7, or 8 or Windows Server 2003 or 2008
  • NVIDIA CUDA Toolkit (available at no cost from http://www.nvidia.com/content/cuda/cuda-downloads.html)
  • Microsoft Visual Studio 2008 or 2010, or a corresponding version of Microsoft Visual C++ Express

About This Document

This document is intended for readers familiar with Microsoft Windows XP, Microsoft Windows Vista, or Microsoft Windows 7 operating systems and the Microsoft Visual Studio environment. You do not need previous experience with CUDA or experience with parallel computation.

Installing CUDA Development Tools

The installation of CUDA development tools on a system running the appropriate version of Windows consists of a few simple steps:
  • Verify the system has a CUDA-capable GPU.
  • Download the NVIDIA CUDA Toolkit.
  • Install the NVIDIA CUDA Toolkit.
  • Test that the installed software runs correctly and communicated with the hardware.

Verify You Have a CUDA-Capable GPU

To verify that your GPU is CUDA-capable, open the Control Panel (Start >Control Panel) and double click on System. In the System Properties window that opens, click theHardware tab, then Device Manager. Expand theDisplay adapters entry. There you will find the vendor name and model of your graphics card. If it is an NVIDIA card that is listed inhttp://www.nvidia.com/object/cuda_gpus.html, your GPU is CUDA-capable.

The Release Notes for the CUDA Toolkit also contain a list of supported products.

Download the NVIDIA CUDA Toolkit

The NVIDIA CUDA Toolkit is available at http://www.nvidia.com/content/cuda/cuda-downloads.html.

Choose the platform you are using and download the NVIDIA CUDA Toolkit

The NVIDIA CUDA Toolkit contains the 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.

Install the CUDA Software

Before installing the toolkit, you should read the Release Notes, as they provide details on installation and software functionality.

Install the CUDA Toolkit by executing the Toolkit installer and following the on-screen prompts.

Note: The driver and toolkit must be installed for CUDA to function. If you have not installed a stand-alone driver, install the driver from the NVIDIA CUDA Toolkit.

You can choose what to install from the following packages:

  1. Note: If you want to install the CUDA Driver for new hardware, and have already installed the CUDA Driver before, you can launch the CUDA Driver installer from the Start Menu under:

    NVIDIA Corporation\CUDA Toolkit\v5.0, or

    NVIDIA Corporation\CUDA Toolkit\v5.0 (64 bit)

    CUDA DriverThe CUDA Driver installation can be done silently or by using a GUI. A silent installation of the driver is done by enabling that feature when choosing what to install.
    • Silent: Only the display driver will be installed.
    • GUI: A window will appear after the CUDA Toolkit installation if you allowed it at the last dialog with the full driver installation UI. You can choose which features you wish to install.
  2. CUDA ToolkitThe CUDA Toolkit installation defaults to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v#.#, where #.# is version number 3.2 or higher. This directory contains the following:
    Bin\
    the compiler executables and runtime libraries
    Include\
    the header files needed to compile CUDA programs
    Lib\
    the library files needed to link CUDA programs
    Doc\
    the CUDA C Programming Guide, CUDA C Best Practices Guide, documentation for the CUDA libraries, and other CUDA Toolkit-related documentation

    Note: CUDA Toolkit versions 3.1 and earlier installed intoC:\CUDA by default, requiring prior CUDA Toolkit versions to be uninstalled before the installation of new versions. Beginning with CUDA Toolkit 3.2, multiple CUDA Toolkit versions can be installed simultaneously.

  3. CUDA Samples

    The CUDA Samples contain source code for many example problems and templates with Microsoft Visual Studio 2008 and 2010 projects.

    For Windows XP, the samples can be found here:
    C:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\CUDA Samples\v5.0
    For Windows Vista, Windows 7, and Windows Server 2008, the samples can be found here:
    C:\ProgramData\NVIDIA Corporation\CUDA Samples\v5.0
Note: The NVIDIA CUDA Toolkit installer only installs Visual Studio project templates for toolkit version 5.0 and higher. Installing NVIDIA® Nsight™, Visual Studio Edition will install Visual Studio project templates for toolkit versions earlier than CUDA 5.0.

Verify the Installation

Before continuing, it is important to verify that the CUDA programs 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.

Running the Compiled Examples

The version of the CUDA Toolkit can be checked by running nvcc -V in a Command Prompt window. You can display aCommand Prompt window by going to:

Start > All Programs > Accessories > Command Prompt

CUDA Samples include sample programs in both source andcompiled form. To verify a correct configuration of the hardware and software, it is highly recommended that you run thedeviceQuery program located here:

Windows XP:
C:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\CUDA Samples\v5.0\C\bin\win32\Release
Windows Vista, Windows 7, Windows 8, Windows Server 2003, and Windows Server 2008:
C:\ProgramData\NVIDIA Corporation\CUDA Samples\v5.0\C\bin\win32\Release

This assumes that you used the default installation directory structure. (On 64-bit versions of Windows, the directory name ends with\win64\Release.) If CUDA is installed and configured correctly, the output should look similar toFigure 1.

Figure 1. Valid Results from Sample CUDA Device Query Program



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 asdeviceQuery above, ensures that the system and the CUDA-capable device are able to communicate correctly. The output should resembleFigure 2.

Figure 2. Valid Results from Sample CUDA Bandwidth Test Program



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.

To see a graphical representation of what CUDA can do, run the sample Particles executable in:
  • For Windows XP:
    c:\Documents and Settings\All Users\Application Data\CUDA Samples\v5.0\C\bin\win32\Release
    (or …\win64\Release on 64-bit Windows)
  • For Windows Vista, Windows 7, Windows 8, Windows Server 2003, and Windows Server 2008:
    C:\ProgramData\NVIDIA Corporation\CUDA Samples\v5.0\C\bin\win32\Release
    (or …\win64\Release on 64-bit Windows)

Compiling CUDA Programs

The project files in the CUDA Samples have been designed to provide simple, one-click builds of the programs that include all source code. To build the 32-bit or 64-bit Windows projects (for release or debug mode), use the provided*.sln solution files for Microsoft Visual Studio 2008 or 2010 (and likewise for the corresponding versions of Microsoft Visual C++ Express Edition). You can use either the solution files located in each of the examples directories in
CUDA Samples\v5.0\C\<category>\<sample_name>
or the global solution files Samples*.sln located in
CUDA Samples\v5.0\C

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).

Compiling Sample Projects

The bandwidthTest project is a good sample project to build and run. It is located in theNVIDIA Corporation\CUDA Samples\v5.0\C\1_Utilities\bandwidthTest directory.

The output is placed in CUDA Samples\C\v5.0\bin\win32\Release. (As mentioned previously, the\win32 segment of this address will be \win64 on 64-bit versions of Windows.) This location presumes that you used the default installation directory structure. Build the program using the appropriate solution file and run the executable. If all works correctly, the output should be similar to Figure 2.

Sample Projects

The sample projects come in two configurations: debug and release (where release contains no debugging information).

A few of the example projects require some additional setup. The simpleD3D9 example requires the system to have a Direct3D SDK installed and the Visual C++ directory paths (located inTools > Options...) properly configured. Consult the Direct3D documentation for additional details.

These sample projects also make use of the $CUDA_PATH environment variable to locate the CUDA Toolkit and a.rules file to locate and configure the nvcc compiler. The environment variable is set automatically and the .rules file is installed automatically as part of the CUDA Toolkit installation process. The.rules file is installed into $VisualStudioInstallDir\VC\VCProjectDefaults. You can reference this .rules file from your Visual Studio project files when building your own CUDA applications.

Build Customizations for New Projects

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 5.0 Runtime" template will configure your project for use with the CUDA 5.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 theCUDA Toolkit Custom Dir field as desired. Note that the selected toolkit must match the version of the Build Customizations.

Build Customizations for Existing Projects

When adding CUDA acceleration to existing applications, the relevant Visual Studio project file must be updated to include CUDA build customizations. For Visual Studio 2010, this can be done using one of the following two methods:
  1. Open the Visual Studio 2010 project, right click on the project name, and selectBuild Customizations..., then select the CUDA Toolkit version you would like to target.
  2. Alternatively, you can configure your project always to build with the most recently installed version of the CUDA Toolkit. First add a CUDA build customization to your project as above. Then, right click on the project name and selectProperties. Under CUDA C/C++, selectCommon, and set the CUDA Toolkit Custom Dir field to $(CUDA_PATH) .

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.

Note for advanced users: If you wish to try building your project against a newer CUDA Toolkit without making changes to any of your project files, go to the Visual Studio 2010 command prompt, change the current directory to the location of your project, and execute a command such as the following:
msbuild <projectname.extension> /t:Rebuild /p:CudaToolkitDir="drive:/path/to/new/toolkit/"

Additional Considerations

Now that you have CUDA-capable hardware and the software installed, you can examine and enjoy the numerous included programs. To begin using CUDA to accelerate the performance of your own applications, consult theCUDA 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 athttp://developer.nvidia.com/cuda/.

Notices

Notice

ALL NVIDIA DESIGN SPECIFICATIONS, REFERENCE BOARDS, FILES, DRAWINGS, DIAGNOSTICS, LISTS, AND OTHER DOCUMENTS (TOGETHER AND SEPARATELY, "MATERIALS") ARE BEING PROVIDED "AS IS." NVIDIA MAKES NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.

Information furnished is believed to be accurate and reliable. However, NVIDIA Corporation assumes no responsibility for the consequences of use of such information or for any infringement of patents or other rights of third parties that may result from its use. No license is granted by implication of otherwise under any patent rights of NVIDIA Corporation. Specifications mentioned in this publication are subject to change without notice. This publication supersedes and replaces all other information previously supplied. NVIDIA Corporation products are not authorized as critical components in life support devices or systems without express written approval of NVIDIA Corporation.

Trademarks

NVIDIA and the NVIDIA logo are trademarks or registered trademarks of NVIDIA Corporation in the U.S. and other countries. Other company and product names may be trademarks of the respective companies with which they are associated.

Copyright

© 2007-2012 NVIDIA Corporation. All rights reserved.



支持的顯卡

CUDA-Enabled Tesla GPU Computing Products

Tesla
Tesla Workstation Products
GPU Compute Capability
Tesla C2075 2.0
Tesla C2050/C2070 2.0
Tesla C1060 1.3
Tesla C870 1.0
Tesla D870 1.0
Tesla Data Center Products
GPU Compute Capability
Tesla K20 3.5
Tesla K10 3.0
Tesla M2050/M2070/M2075/M2090 2.0
Tesla S1070 1.3
Tesla M1060 1.3
Tesla S870 1.0

CUDA-Enabled Quadro Products

Quadro
Quadro Desktop Products
GPU Compute Capability
Quadro K5000 3.0
Quadro 6000 2.0
Quadro 5000 2.0
Quadro 4000 2.0
Quadro 4000 for Mac 2.0
Quadro 2000 2.1
Quadro 2000D 2.1
Quadro 600 2.1
Quadro FX 5800 1.3
Quadro FX 5600 1.0
Quadro FX 4800 1.3
Quadro FX 4800 for Mac 1.3
Quadro FX 4700 X2 1.1
Quadro FX 4600 1.0
Quadro FX 3800 1.3
Quadro FX 3700 1.1
Quadro FX 1800 1.1
Quadro FX 1700 1.1
Quadro FX 580 1.1
Quadro FX 570 1.1
Quadro FX 470 1.1
Quadro FX 380 1.1
Quadro FX 380 Low Profile 1.2
Quadro FX 370 1.1
Quadro FX 370 Low Profile 1.1
Quadro CX 1.3
Quadro NVS 450 1.1
Quadro NVS 420 1.1
NVIDIA NVS 300 1.2
Quadro NVS 295 1.1
Quadro Plex 7000 2.0
Quadro Plex 2200 D2 1.3
Quadro Plex 2100 D4 1.1
Quadro Plex 2100 S4 1.0
Quadro Mobile Products
GPU Compute Capability
Quadro K500M 3.0
Quadro 5010M 2.0
Quadro 5000M 2.0
Quadro 4000M 2.1
Quadro 3000M 2.1
Quadro 2000M 2.1
Quadro 1000M 2.1
Quadro FX 3800M 1.1
Quadro FX 3700M 1.1
Quadro FX 3600M 1.1
Quadro FX 2800M 1.1
Quadro FX 2700M 1.1
Quadro FX 1800M 1.2
Quadro FX 1700M 1.1
Quadro FX 1600M 1.1
Quadro FX 880M 1.2
Quadro FX 770M 1.1
Quadro FX 570M 1.1
Quadro FX 380M 1.2
Quadro FX 370M 1.1
Quadro FX 360M 1.1
Quadro NVS 320M 1.1
Quadro NVS 160M 1.1
Quadro NVS 150M 1.1
Quadro NVS 140M 1.1
Quadro NVS 135M 1.1
Quadro NVS 130M 1.1

CUDA-Enabled NVS Products

NVS
Desktop Products
GPU Compute Capability
Quadro NVS 450 1.1
Quadro NVS 420 1.1
NVIDIA NVS 300 1.2
Quadro NVS 295 1.1
Mobile Products
GPU Compute Capability
NVS 4200M 2.1
NVS 5100M 1.2
NVS 3100M 1.2
NVS 2100M 1.2

CUDA-Enabled GeForce Products

GeForce 8, 9, 100, 200, 400-series, 500-series, and 600-series GPUs with a minimum of 256MB of local graphics memory.

GeForce
GeForce Desktop Products
GPU Compute Capability
GeForce GTX 690 3.0
GeForce GTX 680 3.0
GeForce GTX 670 3.0
GeForce GTX 660 Ti 3.0
GeForce GTX 660 3.0
GeForce GTX 650 Ti 3.0
GeForce GTX 650 3.0
GeForce GTX 560 Ti 2.1
GeForce GTX 550 Ti 2.1
GeForce GTX 460 2.1
GeForce GTS 450 2.1
GeForce GTS 450* 2.1
GeForce GTX 590 2.0
GeForce GTX 580 2.0
GeForce GTX 570 2.0
GeForce GTX 480 2.0
GeForce GTX 470 2.0
GeForce GTX 465 2.0
GeForce GTX 295 1.3
GeForce GTX 285 1.3
GeForce GTX 285 for Mac 1.3
GeForce GTX 280 1.3
GeForce GTX 275 1.3
GeForce GTX 260 1.3
GeForce GT 640 2.1
GeForce GT 630 2.1
GeForce GT 620 2.1
GeForce GT 610 2.1
GeForce GT 520 2.1
GeForce GT 440 2.1
GeForce GT 440* 2.1
GeForce GT 430 2.1
GeForce GT 430* 2.1
GeForce GT 420* 1.0
GeForce GT 240 1.2
GeForce GT 220* 1.2
GeForce 210* 1.2
GeForce GTS 250 1.1
GeForce GTS 150 1.1
GeForce GT 130* 1.1
GeForce GT 120* 1.1
GeForce G100* 1.1
GeForce 9800 GX2 1.1
GeForce 9800 GTX+ 1.1
GeForce 9800 GTX 1.1
GeForce 9600 GSO 1.1
GeForce 9500 GT 1.1
GeForce 8800 GTS 1.1
GeForce 8800 GT 1.1
GeForce 8800 GS 1.1
GeForce 8600 GTS 1.1
GeForce 8600 GT 1.1
GeForce 8500 GT 1.1
GeForce 8400 GS 1.1
GeForce 9400 mGPU 1.1
GeForce 9300 mGPU 1.1
GeForce 8300 mGPU 1.1
GeForce 8200 mGPU 1.1
GeForce 8100 mGPU 1.1
GeForce 8800 Ultra 1.0
GeForce 8800 GTX 1.0
GeForce GT 340* 1.0
GeForce GT 330* 1.0
GeForce GT 320* 1.0
GeForce 315* 1.0
GeForce 310* 1.0
GeForce 9800 GT 1.0
GeForce 9600 GT 1.0
GeForce 9400GT 1.0
GeForce Notebook Products
GPU Compute Capability
GeForce GTX 680MX 3.0
GeForce GTX 680M 3.0
GeForce GTX 675MX 3.0
GeForce GTX 675M 2.1
GeForce GTX 670MX 3.0
GeForce GTX 670M 2.1
GeForce GTX 660M 3.0
GeForce GT 650M 3.0
GeForce GT 645M 3.0
GeForce GT 640M 3.0
GeForce GT 640M LE 3.0
GeForce GT 635M 2.1
GeForce GT 630M 2.1
GeForce GT 625M 2.1
GeForce GT 620M 2.1
GeForce 610M 2.1
GeForce GTX 580M 2.1
GeForce GTX 570M 2.1
GeForce GTX 560M 2.1
GeForce GT 555M 2.1
GeForce GT 550M 2.1
GeForce GT 540M 2.1
GeForce GT 525M 2.1
GeForce GT 520MX 2.1
GeForce GT 520M 2.1
GeForce GTX 485M 2.1
GeForce GTX 470M 2.1
GeForce GTX 460M 2.1
GeForce GT 445M 2.1
GeForce GT 435M 2.1
GeForce GT 420M 2.1
GeForce GT 415M 2.1
GeForce GTX 480M 2.0
GeForce GTS 360M 1.2
GeForce GTS 350M 1.2
GeForce GT 335M 1.2
GeForce GT 330M 1.2
GeForce GT 325M 1.2
GeForce GT 240M 1.2
GeForce G210M 1.2
GeForce 310M 1.2
GeForce 305M 1.2
GeForce GTX 285M 1.1
GeForce GTX 280M 1.1
GeForce GTX 260M 1.1
GeForce 9800M GTX 1.1
GeForce 8800M GTX 1.1
GeForce GTS 260M 1.1
GeForce GTS 250M 1.1
GeForce 9800M GT 1.1
GeForce 9600M GT 1.1
GeForce 8800M GTS 1.1
GeForce 9800M GTS 1.1
GeForce GT 230M 1.1
GeForce 9700M GT 1.1
GeForce 9650M GS 1.1
GeForce 9700M GT 1.1
GeForce 9650M GS 1.1
GeForce 9600M GT 1.1
GeForce 9600M GS 1.1
GeForce 9500M GS 1.1
GeForce 8700M GT 1.1
GeForce 8600M GT 1.1
GeForce 8600M GS 1.1
GeForce 9500M G 1.1
GeForce 9300M G 1.1
GeForce 8400M GS 1.1
GeForce G210M 1.1
GeForce G110M 1.1
GeForce 9300M GS 1.1
GeForce 9200M GS 1.1
GeForce 9100M G 1.1
GeForce 8400M GT 1.1
GeForce G105M 1.1



注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2021 ITdaan.com