Windows平台CUDA开发之前的准备工作

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,造成笔者反复安装配置了多次,奔溃。。。。)

NVIDIA CUDA Getting Started Guide for Microsoft Windows

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

1.1. System
Requirements

To use CUDA on your system, you will need the following installed:

The next two tables list the currently supported Windows operating systems and compilers.

Table 1. Windows Operating System Support in CUDA 7.0
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
Table 2. Windows Compiler Support in CUDA 7.0
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.

x86
32-bit Support

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.

Support for developing and running x86 32-bit applications on x86_64 Windows is limited to use with:

  • GeForce GPUs
  • CUDA Driver
  • CUDA Runtime (cudart)
  • CUDA Math Library (math.h)
  • CUDA C++ Compiler (nvcc)
  • CUDA Development Tools

1.2. About
This Document

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.

2. Installing CUDA Development Tools

The setup 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 communicates with the hardware.

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

2.2. Download
the NVIDIA CUDA Toolkit

The NVIDIA CUDA Toolkit is available at http://developer.nvidia.com/cuda-downloads. Choose the platform
you are using and one of the following installer formats:

  1. Network Installer: A minimal installer which later downloads packages required for installation. Only the packages selected during the selection phase of the installer are downloaded. This installer is useful for users who want to minimize download
    time.
  2. Full Installer: An installer which contains all the components of the CUDA Toolkit and does not require any further download. This installer is useful for systems which lack network access and for enterprise deployment.

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.

Download Verification

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.

2.3. Install
the CUDA Software

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

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.

Note: The installation may fail if Windows Update starts after the installation has begun. Wait until Windows Update is complete and then
try the installation again.

Graphical Installation

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

Silent Installation

Alternatively, the installer can be executed in silent mode by executing the package with the -s flag.
Additional flags can be passed which will install specific subpackages instead of all packages. Allowed subpackage names are: CUDAToolkit_7.0, CUDASamples_7.0,
CUDAVisualStudioIntegration_7.0, and Display.Driver. For example, to install only the driver and the toolkit components:

<PackageName>.exe -s CUDAToolkit_7.0 Display.Driver

Subpackage Details

  • Display Driver

    Required to run CUDA applications.

  • CUDA Toolkit

    The CUDA Toolkit installation defaults to C:\Program
    Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0. 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 documentation, including:

    • CUDA C Programming Guide
    • CUDA C Best Practices Guide
    • documentation for the CUDA libraries
    • other CUDA Toolkit-related documentation
  • 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.

    Note:C:\ProgramData\ is
    a hidden folder. It can be made visible within Windows Explorer by enabling it through the menu options within Windows Explorer (Tools | Options).

Extracting and Inspecting the Files Manually

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.

Note: Accessing the files in this manner does not set up any environment settings, such as variables or Visual Studio integration. This
is intended for enterprise-level deployment.

2.3.1. Uninstalling
the CUDA Software

All subpackages can be uninstalled through the Windows Control Panel by using the Programs and Features widget.

2.4. Use
a Suitable Driver Model

On Windows 7 and later, the operating system provides two driver models under which the NVIDIA Driver may operate:

  • The WDDM driver model is used for display devices.
  • The Tesla Compute Cluster (TCC) mode of the NVIDIA Driver is available for non-display
    devices such as NVIDIA Tesla GPUs; it uses the Windows WDM driver model.

The TCC driver mode provides a number of advantages for CUDA applications on GPUs that support this mode. For example:

  • TCC eliminates the timeouts that can occur when running under WDDM due to the Windows Timeout
    Detection and Recovery
     mechanism for display devices.
  • TCC allows the use of CUDA with Windows Remote Desktop, which is not possible for WDDM devices.
  • TCC allows the use of CUDA from within processes running as Windows services, which is not possible for WDDM devices.
  • TCC reduces the latency of CUDA kernel launches.

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

Note: Keep in mind that when TCC mode is enabled for a particular GPU, that GPU cannot be
used as a display device.

Note: NVIDIA GeForce GPUs do not support TCC mode.

2.5. Verify
the Installation

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.

2.5.1. 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 a Command Prompt window by going to:

Start > All Programs > Accessories > Command Prompt

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

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
.

Figure 1. Valid Results from deviceQuery CUDA Sample

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
.

Figure 2. Valid Results from bandwidthTest CUDA Sample

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 at

C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.0\bin\win64\Release

3. 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 Windows projects (for release or debug mode), use the provided *.sln solution
files for Microsoft Visual Studio 2010, 2012, or 2013. You can use either the solution files located in each of the examples directories in

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

3.1. Compiling
Sample Projects

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
.

3.2. Sample
Projects

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

For Visual Studio 2010, the CUDA 7.0.props file
is installed into:

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations

For Visual Studio 2012, the CUDA 7.0.props file
is installed into:

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations

For Visual Studio 2013, the CUDA 7.0.props file
is installed into:

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.

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

3.4. Build
Customizations for Existing Projects

When adding CUDA acceleration to existing applications, the relevant Visual Studio project files must be updated to include CUDA build customizations. This can be done using one of the following two methods:

  1. Open the Visual Studio project, right click on the project name, and select Build 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 select Properties.
    Under CUDA C/C++, select Common, and set the CUDA Toolkit Custom Dir field to $(CUDA_PATH) .
    Note that the $(CUDA_PATH) environment variable is
    set by the installer.

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.

If you use the $(CUDA_PATH) environment
variable to target a version of the CUDA Toolkit for building, and you perform an installation or uninstallation of any version of the CUDA Toolkit, you should validate that the $(CUDA_PATH) environment
variable points to the correct installation directory of the CUDA Toolkit for your purposes. You can access the value of the $(CUDA_PATH) environment
variable via the following steps:

  1. Open a run window from the Start Menu
  2. Run:
    control sysdm.cpl
  3. Select the "Advanced" tab at the top of the window
  4. Click "Environment Variables" at the bottom of the window

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
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/"

4. Additional Considerations

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

以上英文内容转自:

http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-microsoft-windows/index.html#axzz3W8BU10Ol

时间: 2024-11-04 15:03:22

Windows平台CUDA开发之前的准备工作的相关文章

Eclipse(RustDT) + Racer + Windows 平台Rust开发环境搭建

[ 声明:版权所有,转载请注明出处,请勿用于商业用途. 联系信箱:[email protected]] 1.Rust 1.1 安装Rust 前往Rust官网下载各Windows平台安装文件,这里推荐大家下载稳定版.如果下载速度较慢,大家也可以点击打开百度云盘进行下载.下载完成后即可开始安装.整个安装过程都比较简单,Windows用户打开.msi安装文件.这里建议大家选择 高级模式,这样更加灵活,同时可以开启安装完成后自动添加环境变量到系统的功能.如图: 安装完成后,可以打开控制台,输入rust

Windows平台开发Mapreduce程序远程调用运行在Hadoop集群—Yarn调度引擎异常

共享原因:虽然用一篇博文写问题感觉有点奢侈,但是搜索百度,相关文章太少了,苦苦探寻日志才找到解决方案. 遇到问题:在windows平台上开发的mapreduce程序,运行迟迟没有结果. Mapreduce程序 public class Test { public static void main(String [] args) throws Exception{ Configuration conf = new Configuration(); conf.set("fs.defaultFS&qu

Windows平台开发实用工具(C++)

本文列举记录了本人从事Windows平台软件开发两年以来使用的工具,持续更新中. 1. 文本编辑类 Notepad++ Notepad++是Windows操作系统下的一套文本编辑器,有完整的中文化接口及支持多国语言编写的功能.除了适合制作一般的纯文字说明文件,也十分适合编写计算机程序代码.Notepad++不仅有语法高亮度显示,也有语法折叠功能,并且支持宏以及扩充基本功能的外挂模组.程序员最爱! 下载地址:https://notepad-plus.en.softonic.com/ Beyond

Linux下编译静态MinGW环境,编译windows平台Qt程序(使用MXE)

参考链接: MXE.>大多数程序都是在windows平台下开发的程序.windows 在现实中也是绕不过的一个系统平台,做为受过几年VC,MFC”虐待”的程序员,在做为一个程序员之前是一位Linux重度使用者,受够了MFC之后一直想要找一个框架替换,使用过GTK,wxWidgets,Qt,最后还是Qt用得多一些.我认为程序跨平台应该是一个基本标准,同一份代码不需改动,或者改动极少,放在不同的平台下编译就能使用.不同平台,同样的界面,同样的操作,同样的体验.这里要讲的是我如何在Linux 下开发跨

在Windows*上极速飞艇平台定制开发编译Tensorflow教程

最简单极速飞艇平台定制开发[大神源码论坛]dsluntan.com [布丁源码论坛]budingbbs.com 企娥3393756370的 Tensorflow 的安装方法是在 pip 一键式安装官方预编译好的包 pip install tensorflow 通常这种预编译的包的编译参数选择是为了最大兼容性而不是为了最优性能,导致在使用过程中,每次运行代码都会输出一大堆的 warning 信息.例如在安装了谷歌官方的 Tensorflow 1.3.0 包后,运行以下测试代码时 import te

基于科大讯飞语音云windows平台开发

前记: 前段时间公司没事干,突发奇想想做一个语音识别系统,看起来应该很简单的,但做起来却是各种问题,这个对电气毕业的我,却是挺为难的.谷姐已经离我们而去,感谢度娘,感谢CSDN各位大神,好歹也做的是那么回事了,虽然还是不好用,但基本功能实现了. 该软件使用VS2008C++/CLR开发,由于科大讯飞提供的是C的API接口,结果到这边就是各种不兼容,CLR是基于托管堆运行的,而这个API有是非托管堆的,使用了各种指针,原本打算使用C#来做,最后门外汉的我也没能做到C#和C指针完美结合,真怀恋单片机

[转]微信公众平台(测试接口)开发前的准备工作(转载自walkingmanc的专栏)

本文转自:http://blog.csdn.net/jiangweicpu/article/details/21228949 http://blog.csdn.net/walkingmanc/article/details/21457097第二讲 探秘微信公众号 1.   申请微信公众号 我们要进行微信公众平台的开发,第一步当然是要有公众号了.什么?不知道什么是微信公众号,看来你还要先回炉炼炼了,呵呵.通俗的说,我们微信平台就好像是一个大社会,里面有个体人,也有各种组织机构.你自己使用的普通微信

在Windows平台搭建C语言开发环境的多种方式

新接触C语言,如何进行C语言开发环境的搭建值得思考并整理 注:本文知识来源于  Windows 平台搭建C语言集成开发环境 - 极客学院 一.在Windows平台配置GNU环境 二.在Windows平台使用Sublime Test开发C语言程序 三.在Windows平台使用VisualStudio开发C语言程序 四.在Windows平台搭建EclipseCDT集成开发环境 五.在Windows平台搭建Clion集成开发环境 一.在Windows平台配置GNU环境 GNU http://www.g

Cocos2d-x--iOS平台lua加密成luac资源方法和Jsc文件&lt;MAC平台开发试用--windows平台暂未研究&gt;

    首先要说,最近真的是太忙了,好久没写博客了,今天正好有空,就写一下最近在写游戏中的一些发现: 话说,基于Cocos2dx 引擎 + 脚本写游戏,至今的感触就是可以进行增量更新和即时编译等,节省了很多时间:好了废话不多说了,进入正题: 这里我是以Cocos2d-x-2.2.2 为例<其实,写着文章时候Cocos2d-x-3.2 都封版了>: 今天我就说一下怎么用Cocos2d-x3.2中的cocos-console 去 批量 加密lua脚本-变成luac文件 ,js文件变成jsc加密文