在windows下安装cuda
CUDA2[1].3、3.2、4.0安装总结
![CUDA2[1].3、3.2、4.0安装总结](https://img.taocdn.com/s3/m/0b50921bc281e53a5802ff0d.png)
tllovejf1 2011\9\25Windows平台配置CUDA编译环境一、CUDA2.3(CUDA2.3具有Emudebug调试功能)(注:CUDA3.2配置同2.3一样)安装步骤:1.平台:Windows7 SP1 旗舰版X64+VS2008SP1;2.安装VS2008时,选择自定义,勾选X64编译器(很重要);3.根据自己的显卡,依次安装CUDA drivers,cudatoolkit_2.3_win_64,cudasdk_2.3_win_64;(路径默认就行,中间过程都选完全安装)下载地址:/cuda-toolkit-23-downloads4.运行CUDA_VS_Wizard_W64.2.2;5.在系统环境变量,PATH环境变量最后添加“Debug;EmuDebug;Release;EmuRelease”的路径(很重要)。
例如CUDASDK按默认路径安装则添加:C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\bin\win64\Debug;C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\bin\win64\EmuDebug;C:\ProgramData\NVIDIACorporation\NVIDIAGPU Computing SDK\C\bin\win64\EmuRelease;C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\bin\win64\Release;6.测试例子:新建项目->cuda64->sample.cu;7.高亮配置:(1)打开VS, 选择:工具->选项->项目与解决方案->VC++项目设置,在“C/C++文件扩展名”后添加*.cu,在“包括的扩展名”后添加.cu;(2)打开Visual AssistantX设置,在Projects->C/C++ Directories 里,Platform选择Custom,Show Directories for选择Stable include files,添加CUDA Toolkit的include目录路径;注意:如果高亮还有问题可以再添加:CUDA Toolkit的lib64,bin64,common\inc等目录路径。
Windows搭建CUDA开发环境

Windows搭建CUDA开发环境CUDA(Compute Unified Device Architecture,统⼀计算架构)是由英伟达所推出的⼀种集成技术,向⽤户提供了可以很优雅地调⽤GPU进⾏并⾏计算的编程接⼝。
然⽽对于很多刚接触这门技术的⼈来说,怎么把⼀个简单的cuda程序跑起来却也是⼀个“说⼤不⼤,说⼩不⼩”的问题。
我⼤致整理出了在Windows上搭建cuda开发环境的⽅案,勉勉强强可以被当作⼀份参考。
此处我的⽬标主要为:完成对简单CUDA C程序的编译和运⾏。
当然,要搭建⼀个真实的cuda开发环境,得先确保⾃⼰电脑是⽀持cuda的。
(安装了英伟达显卡的应该都没问题)命令⾏编译⾸先去英伟达官⽹下载⼀个,然后安装上。
安装完成后,试试nvcc -V查看是否是否能正常使⽤nvcc,如果不能的话,去环境变量中检查⼀下类似C:\Program Files\NVIDIA GPUComputing Toolkit\CUDA\v11.1\bin\这样的值有没有被加到Path⾥,如果没有的话记得⼿动加⼀下(记得使⽤⾃⼰的真实的CUDA⼯具包的安装位置,不要直接复制我这⾥的)。
添加完成后记得要重新打开⼀个cmd或shell才能正常加载。
创建⼀个cuda程序hello.cu,参考程序附于⽂末;在当前⽬录使⽤nvcc -o hello hello.cu进⾏编译,如果⼀切正常,这个⽬录中将出现hello.exe, hello.exp, hello.lib这⼏个⽂件。
但通常来说,这⾥会出现找不到cl的情况。
如果没有安装Visual Studio的话,先安装⼀个找到cl.exe的位置,并将该⽬录加⼊到环境变量Path中,我这⾥给出⼀个参考:D:\Program Files (x86)\Microsoft VisualStudio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\Hostx64\x64使⽤Visual Studio⾸先如果没有安装VC的话当然是需要先安装⼀个,⾄于安装的时候具体要选哪些模块,我现在也还不是很清楚,也没来得及去验证。
CUDA4.0 X32 + Windows7 32bit + Visual Studio2008+ Visual Assist安装指南

CUDA4.0 X32 + Windows7 32bit + Visual Studio2008+ Visual Assist安装指南1,需要安装的软件:CUDA Toolkit4.0 + GPUComputing SDK + CUDA Wizard + +对应的显卡驱动+ Visual Assist破解版+ VS2008下载地址:/cuda-toolkit-402,先安装显卡,得确保显卡支持CUDA加速。
查询是否支持可看此网站:/cuda-gpus3,再安装Toolkit4.0和SDK,最好选择默认。
在Win7环境下,Toolkit4.0安装后文件路径为:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2SDK默认安装文件路径为:C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0,注意:ProgramData Win7为隐藏文件,XP系统下默认安装路径为C:\Documents and Settings\All Users\ApplicationData\NVIDIACorporation\NVIDIA GPU Computing SDK 4.04,C:\ProgramData\NVIDIACorporation\NVIDIA GPU Computing SDK 4.0\C\src该目录下,为SDK所带的demo程序,有VS2005、VS2008和VS2010三个版本。
5,安装CUDAWizard,下载地址:/projects/cudavswizard/安装后,重新打开VS2008,此时【新建项目类型】多了【CUDA】一项,此时可以新建CUDA C程序了。
但此时肯定编译通不过,缺少必要的环境变量设置。
6,Ctrl+R,输入cmd,进入命令提示窗口输入setcuda,看是否出现以CUDA开头的环境变量,如果没有,说明SDK安装不正确,重新安装之后,在环境变量中设置【用户变量】中的【path】,添加上C:\ProgramData\NVIDIACorporation\NVIDIA GPU Computing SDK 4.0\C\bin\win32\Debug和C:\ProgramData\NVIDIACorporation\NVIDIA GPU Computing SDK 4.0\C\bin\win32\Release7,打开VS2008,【工具】-【选项】-【项目和解决方案】-【VC++目录】-【包含文件】添加上C:\ProgramFiles\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include、和C:\ProgramData\NVIDIACorporation\NVIDIA GPU Computing SDK 4.0\C\common\inc【库文件】添加上C:\ProgramFiles\NVIDIA GPU Computing Toolkit\CUDA\v4.0\lib和C:\ProgramData\NVIDIACorporation\NVIDIA GPU Computing SDK 4.0\C\common\lib【源文件】添加上C:\ProgramData\NVIDIACorporation\NVIDIA GPU Computing SDK 4.0\C\common\src8,【工具】-【选项】-【项目和解决方案】-【VC++项目设置】-【C/C++文件扩展名】添加上*.cu【包括的扩展名】添加上.cuh【规则文件搜索路径】C:\ProgramData\NVIDIACorporation\NVIDIA GPU Computing SDK 4.0\C\common9,产生一些必须的库文件打开文件夹C:\ProgramData\NVIDIACorporation\NVIDIA GPU Computing SDK 4.0\C\common用VS打开Release_vs2008.sln(包含有cutil_vs2008和rendercheckgl_vs2008项目),选择【生成】-【批生成】,选择【Debug|Win32】和【Release|Win32】,点击【生成】,即可生成一些必须的库文件。
windows10安装cuda10.1+pytorch1.4

windows10安装cuda10.1+pytorch1.4windows10 版本号:1909 操作系统版本:18363.7780x1 确定 nvidia 显卡驱动的版本是否满⾜安装条件1. 打开 nvidia 控制⾯板,看到我的显卡为 GTX1060 驱动版本为445.752. 进⼊,查看 CUDA 版本与 nvidia 显卡驱动版本之间的关系我们要安装的是 CUDA10.1,可以看到在 64 位 Windows 下 nvidia 显卡驱动版本⼤于418.96即可安装。
0x2 下载CUDA与cuDNNCUDA是⼀种由NVIDIA推出的通⽤并⾏计算架构,cuDNN是⽤于深度神经⽹络的GPU加速库。
要能够运⾏gpu版本的tensorflow和pytorch 等框架,需要同时安装这两个模块。
1. 下载CUDA10.1进⼊,下载windows10版本的exe(local),点击直接下载2. 添加环境变量C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\lib\x64安装完重启电脑,验证cuda是否安装成功$ nvcc -V3. 下载CUDA对应的cuDNN进⼊,需要登录,没有账号的注册⼀个即可,点击直接下载4. 将cuDNN下载得到的三个⽂件夹⾥的⽂件复制到CUDA对应的三个⽂件夹⾥打开环境变量查看CUDA的安装⽬录打开C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1,依次复制⽂件夹⾥⾯的⽂件到对应的⽂件夹。
(注意是把⾥⾯的⽂件复制过去,分别为cudnn.lib、cudnn.h、cudnn64_7.dll检验cudnn是不是安装成功(不要把命令中引号删了,下同)$ "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\extras\demo_suite\deviceQuery.exe"看到PASS$ "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\extras\demo_suite\bandwidthTest.exe"看到PASS,则cuDNN安装成功0x3 安装anaconda去下载anaconda windows 64位版本,点击直接下载0x4 安装pytorch1.4 与torchvision1. 创建conda环境$ conda create -n myenv python==3.6.5这个表⽰安装⼀个名字为myenv的环境,并同时安装python版本为3.6.5不要使⽤python3.6.0版本,⾎的教训,安装pytorch后会报找不到dll模块的错误。
cuda 升级 方法

cuda 升级方法
升级CUDA的方法包括以下步骤:
1. 卸载nvidia驱动:首先,您需要卸载当前的nvidia驱动。
可以使用以下命令在终端中执行此操作:
```sql
sudo apt-get remove nvidia
```
请注意,这将卸载与NVIDIA相关的一切,如果此时重新启动电脑可能会导致无法进入系统。
2. 安装新的cuda:然后,您需要安装新的CUDA版本。
首先,前往NVIDIA官网下载最新的CUDA,并确保选择的是Deb格式的安装包。
下载完成后,使用以下命令在终端中执行安装:
```bash
sudo dpkg -i cuda-repo-ubuntuXXXX_X-X_
sudo apt-key adv --fetch-keys
sudo apt-get update
sudo apt-get install cuda
```
请将"XXXX"替换为您的Ubuntu版本号。
3. 验证安装:安装完成后,您可以通过运行以下命令来验证CUDA是否成功安装:
```css
nvcc --version
```
这将显示已安装的CUDA版本信息。
通过上述步骤,您可以成功升级CUDA版本。
请记住在进行升级之前备份重要数据,并确保您的系统满足新版本的最低要求。
NVIDIA CUDA 安装指南(微软 Windows)说明书

DU-05349-001_v9.0 | September 2017Installation and Verification on WindowsTABLE OF CONTENTS Chapter 1. Introduction (1)1.1. System Requirements (1)1.1.1. x86 32-bit Support (2)1.2. About This Document (3)Chapter 2. Installing CUDA Development T ools (4)2.1. Verify You Have a CUDA-Capable GPU (4)2.2. Download the NVIDIA CUDA T oolkit (4)2.3. Install the CUDA Software (5)2.3.1. Uninstalling the CUDA Software (7)2.4. Use a Suitable Driver Model (8)2.5. Verify the Installation (8)2.5.1. Running the Compiled Examples (8)Chapter 3. Compiling CUDA Programs (11)3.1. Compiling Sample Projects (11)3.2. Sample Projects (11)3.3. Build Customizations for New Projects (12)3.4. Build Customizations for Existing Projects (12)Chapter 4. Additional Considerations (14)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 existingapplications. 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 RequirementsTo use CUDA on your system, you will need the following installed:‣ A CUDA-capable GPU‣ A supported version of Microsoft Windows‣ A supported version of Microsoft Visual Studio‣the NVIDIA CUDA Toolkit (available at /cuda-downloads)The next two tables list the currently supported Windows operating systems and compilers.T able 1 Windows Operating System Support in CUDA 9.0T able 2 Windows Compiler Support in CUDA 9.0x86_32 support is limited. See the x86 32-bit Support section for details.1.1.1. x86 32-bit SupportNative 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 Tools1.2. About This DocumentThis 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.Basic instructions can be found in the Quick Start Guide. Read on for more detailed instructions.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 GPUYou can verify that you have a CUDA-capable GPU through the Display Adapters section in the Windows Device Manager. Here you will find the vendor name and model of your graphics card(s). If you have an NVIDIA card that is listed in http:// /cuda-gpus, that GPU is CUDA-capable. The Release Notes for the CUDA Toolkit also contain a list of supported products.The Windows Device Manager can be opened via the following steps:1.Open a run window from the Start Menu2.Run:control /name Microsoft.DeviceManager2.2. Download the NVIDIA CUDA T oolkitThe NVIDIA CUDA Toolkit is available at /cuda-downloads. Choose the platform you are using and one of the following installer formats:work Installer: A minimal installer which later downloads packages required forinstallation. Only the packages selected during the selection phase of the installerare 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 Toolkitand does not require any further download. This installer is useful for systemswhich 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 VerificationThe download can be verified by comparing the MD5 checksum posted at http:// /cuda-downloads/checksums with that of the downloadedfile. 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:// /kb/889768.2.3. Install the CUDA SoftwareBefore installing the toolkit, you should read the Release Notes, as they provide details on installation and software functionality.The driver and toolkit must be installed for CUDA to function. If you have notinstalled a stand-alone driver, install the driver from the NVIDIA CUDA T oolkit.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 InstallationInstall the CUDA Software by executing the CUDA installer and following the on-screen prompts.Silent InstallationThe installer can be executed in silent mode by executing the package with the -s flag. Additional parameters can be passed which will install specific subpackages instead of all packages. See the table below for a list of all the subpackage names.T able 3 Possible Subpackage NamesFor example, to install only the compiler and driver components:<PackageName>.exe -s compiler_9.0 Display.DriverExtracting and Inspecting the Files ManuallySometimes 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 isa .dll and .nvi file that can be ignored as they are not part of the installable files.Accessing the files in this manner does not set up any environment settings, suchas variables or Visual Studio integration. This is intended for enterprise-leveldeployment.2.3.1. Uninstalling the CUDA SoftwareAll subpackages can be uninstalled through the Windows Control Panel by using the Programs and Features widget.2.4. Use a Suitable Driver ModelOn 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, and the GeForce GTX Titan 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).Keep in mind that when TCC mode is enabled for a particular GPU, that GPU cannotbe used as a display device.NVIDIA GeForce GPUs (excluding GeForce GTX Titan GPUs) do not support TCC mode.2.5. Verify the InstallationBefore 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 ExamplesThe 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 PromptCUDA 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 atC:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.0\bin\win64\ReleaseThis 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 SampleThe 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 bandwidthT est CUDA SampleThe 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 atC:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.0\bin\win64\ReleaseThe 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 inC:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.0\<category>\<sample_name>or the global solution files Samples*.sln located inC:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.0CUDA 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 ProjectsThe bandwidthTest project is a good sample project to build and run. It is located in the NVIDIA Corporation\CUDA Samples\v9.0\1_Utilities\bandwidthTest directory.If you elected to use the default installation location, the output is placed in CUDA Samples\v9.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 ProjectsThe 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 9.0.props file, and is installed automatically as part of the CUDA Toolkit installation process.T able 4 CUDA Visual Studio .props locationsYou can reference this CUDA 9.0.props file when building your own CUDA applications.3.3. Build Customizations for New ProjectsWhen 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 9.0 Runtime" template will configure your project for use with the CUDA 9.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 ProjectsWhen 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 BuildCustomizations..., then select the CUDA Toolkit version you would like to target.2.Alternatively, you can configure your project always to build with the most recentlyinstalled 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 fieldto $(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 Menu2.Run:control sysdm.cpl3.Select the "Advanced" tab at the top of the window4.Click "Environment Variables" at the bottom of the windowFiles which contain CUDA code must be marked as a CUDA C/C++ file. This can done when adding the file by right clicking the project you wish to add the file to, selecting Add\New Item, selecting NVIDIA CUDA 9.0\Code\CUDA C/C++ File, and then selecting the file you wish to add.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/"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 /cuda/.NoticeALL NVIDIA DESIGN SPECIFICATIONS, REFERENCE BOARDS, FILES, DRAWINGS, DIAGNOSTICS, LISTS, AND OTHER DOCUMENTS (TOGETHER AND SEPARATEL Y, "MATERIALS") ARE BEING PROVIDED "AS IS." NVIDIA MAKES NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO THE MATERIALS, AND EXPRESSL Y 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.TrademarksNVIDIA 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© 2009-2017 NVIDIA Corporation. All rights reserved.。
在windows下安装cuda(附VNC远程调用CUDA说明)

在windows下安装cuda安装环境在windows下,目前cuda只支持在 Visual Studio 7.x 系列、Visual Studio 8以及免费的 Visual Studio C++ 2005 Express。
所以需要预先安装以上软件中的任意一种。
下面我们以Visual Studio 2005 为例演示cuda的安装。
1、cuda安装包cuda是免费使用的,各种操作系统下的cuda安装包均可以在/object/cuda_get_cn.html上免费下载。
Cuda提供3个安装包,分别是:SDK, Toolkit和Display。
SDK包括许多例子程序和函数库。
Toolkit包括cuda的基本工具。
Display包括了NV显卡的驱动程序。
Toolkit是核心。
2、安装cuda2.1 安装cuda toolkit双击NVIDIA_CUDA_toolkit_2.0_win32.exe安装,安装完成后在安装目录下出现6个文件夹,分别是:Bin :工具程序和动态链接库Doc :相关文档Include : header头文件包Lib :程序库Open64 :基于open64的cuda compilerSrc :部分原始代码安装过程中toolkit自动设定了3个环境变量:CUDA_BIN_PATH、CUDA_INC_PATH和CUDA_LIB_PATH分别对应工具程序库、头文件库和程序库,预设路径为当前安装文件夹下的bin、include 和lib三个文件夹。
2.2 安装CUDA SDKSDK可以根据需要选择安装(推荐安装,因为SDK中的许多例子程序和函数库非常有用)。
2.3 安装 CUDA Display对于没有安装NV显卡的计算机,不需要安装Display安装包,程序也可以在模拟模式下运行。
3、在Visual Studio中使用cudaCUDA的主要工具是nvcc,它会执行所需要的程序,将CUDA程序编译并执行。
windows安装cuda的方法

windows安装cuda的方法
CUDA是NVIDIA公司开发的一个并行计算平台和编程模型,可以让开发者使用GPU来加速应用程序的运算速度。
在Windows操作系统下,安装CUDA可以让开发者在本地环境中进行CUDA程序的编写和测试。
以下是安装CUDA的方法:
1. 下载CUDA安装包
从NVIDIA官网下载与自己显卡型号和操作系统版本相匹配的CUDA安装包。
2. 安装CUDA Toolkit
运行下载的CUDA安装包,按照提示完成安装。
3. 配置环境变量
在环境变量中添加CUDA的路径,以便在命令行中运行CUDA程序。
在系统变量中添加以下两个环境变量:
(1)CUDA_PATH:CUDA安装路径,例如“C:Program FilesNVIDIA GPU Computing ToolkitCUDAv10.1”
(2)PATH:CUDA相关的路径,例如
“%CUDA_PATH%bin;%CUDA_PATH%libnvvp”
4. 安装显卡驱动
安装显卡驱动可以确保CUDA程序能够正常运行。
从NVIDIA官网下载与自己显卡型号和操作系统版本相匹配的显卡驱动程序,运行安装即可。
5. 验证CUDA安装成功
在命令行中输入“nvcc -V”,如果输出CUDA的版本信息,则表示CUDA安装成功。
现在,您已经完成了在Windows操作系统下安装CUDA的全部步骤,可以开始使用CUDA进行并行计算了。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
在windows下安装cuda硬件环境:cuda支持目前NV的市面上的绝大多数显卡,包括Tesla、Quadro、GeForce,只有少数早期的旧型号显卡不支持cuda。
详见/object/cuda_learn_products_cn.html软件环境:cuda可以在Windows(32/64)、Mac OS、Linux(32/64)中的大多数版本中安装。
在windows下,目前cuda只支持在 Visual Studio 7.x 系列、Visual Studio 8以及免费的 Visual Studio C++ 2005 Express。
所以需要预先安装以上软件中的任意一种。
下面我们以Visual Studio 2005 为例演示cuda的安装。
1、cuda安装包cuda是免费使用的,各种操作系统下的cuda安装包均可以在/object/cuda_get_cn.html上免费下载。
Cuda提供3个安装包,分别是:SDK, Toolkit和Display。
SDK包括许多例子程序和函数库。
Toolkit包括cuda的基本工具。
Display包括了NV显卡的驱动程序。
Toolkit是核心。
2、安装cuda2.1 安装cuda toolkit双击NVIDIA_CUDA_toolkit_2.0_win32.exe安装,安装完成后在安装目录下出现6个文件夹,分别是:Bin :工具程序和动态链接库Doc :相关文档Include : header头文件包Lib :静态库Open64 :基于open64的cuda compilerSrc :部分原始代码安装过程中toolkit自动设定了3个环境变量:CUDA_BIN_PATH、CUDA_INC_PATH和CUDA_LIB_PATH分别对应工具程序库、头文件库和程序库,预设路径为当前安装文件夹下的bin、include 和lib三个文件夹。
并将bin文件夹目录加入环境变量path中。
2.2 安装CUDA SDKSDK可以根据需要选择安装(推荐安装,因为SDK中的许多例子程序和函数库非常有用)。
2.3 安装 CUDA Display对于没有安装NV显卡的计算机,不需要安装Display安装包,程序也可以在模拟模式下运行。
3、在Visual Studio中使用cudaCUDA的主要工具是nvcc,它会执行所需要的程序,将CUDA程序编译并执行。
下面介绍了三种配置cuda nvcc的方法。
这里推荐使用第三种方法。
3.1、方法一(NV自带的修改模板方法)3.1.1、在CUDA SDK安装目录下的project目录下新建文件夹,命名为想要建立的工程名字,比如test。
并在project文件夹下找到SDK自带的template文件夹,将template 文件夹下所有的文件copy到test下。
3.1.2、将copy到test文件夹下的所有文件文件名中的template改为test。
test.sln与test.vcproj是vs 8系列的工程文件,test_vc7.sln与test_vc7.vcproj是vs 7系列的工程文件,可以根据自己Visual Studio的版本选择要更改的工程文件,其它两个可以删除。
在Visual Studio C++ 2005 Express中,可以将test_vc7.sln与test_vc7.vcproj删除。
3.1.3、将*.cu、*.sln和*.vcproj用记事本等文字编辑软件打开,使用查找替换功能将以上文件中所有的template改为test。
3.1.4、使用*.sln文件打开整个工程,可以任意更改代码,编译运行。
3.1.5、修改输出文件路径(可选,如不改变,可执行文件输出到上两级目录下的bin 目录中),如使用了CUDA SDK中的动态链接库,将相应的动态链接库拷贝到可执行文件的同一目录下。
总结:这种方法是NV公司为windows下使用vs编译cuda提供的标准方法(参见\SDK\doc\CUDA_SDK_release_notes_windows.txt),使用公司提供的模板更改为自己想要建立的工程,也可以参照以上方法,在SDK Project库中的找到与自己想建立工程相近的其它工程做更改。
但是费时费力,不推荐使用。
3.2、方法二(设定custom build tool执行cuda)3.2.1、首先建立一个win32 console 模式的 empty project,并建立一个新的源文件,此处以main.cu为例。
P1.建立一个win32 projectP2.设定为empty projectP3.建立main.cu3.2.2、在solution explorer 中main.cu上右键单击,选择property。
在打开的对话框中选择General,确定Tool的选项是Custom Build Tool。
P4.确认Tool选项3.2.3、选择Custom Bulid Step,在Command Line中分别设定模式参数(1)、Release 模式:"$(CUDA_BIN_PATH)\nvcc.exe" -ccbin "$(VCInstallDir)bin"-c -DWIN32 -D_CONSOLE -D_MBCS -Xcompiler /EHsc,/W3,/nologo,/Wp64,/O2,/Zi,/MT-I"$(CUDA_INC_PATH)" -o $(ConfigurationName)\$(InputName).obj$(InputFileName)(2)、Debug 模式:"$(CUDA_BIN_PATH)\nvcc.exe" -ccbin "$(VCInstallDir)bin"-c -D_DEBUG -DWIN32 -D_CONSOLE -D_MBCS -Xcompiler/EHsc,/W3,/nologo,/Wp64,/Od,/Zi,/RTC1,/MTd -I"$(CUDA_INC_PATH)" -o$(ConfigurationName)\$(InputName).obj $(InputFileName)P5.设定Command Line参数如果计算机中没有安装NV显卡,使用模拟模式,需增加两个额外的设定。
新建两个模式EmuRelease和EmuDebug。
P6.新建模式(1)P6.新建模式(2)对新建立的EmuRelease和EmuDebug的Command Line分别设定为:(1)、EmuRelease 模式:"$(CUDA_BIN_PATH)\nvcc.exe" -ccbin"$(VCInstallDir)bin" -deviceemu -c -DWIN32 -D_CONSOLE -D_MBCS -Xcompiler /EHsc,/W3,/nologo,/Wp64,/O2,/Zi,/MT -I"$(CUDA_INC_PATH)" -o$(ConfigurationName)\$(InputName).obj $(InputFileName)(2)、EmuDebug 模式:"$(CUDA_BIN_PATH)\nvcc.exe" -ccbin"$(VCInstallDir)bin" -deviceemu -c -D_DEBUG -DWIN32 -D_CONSOLE -D_MBCS -Xcompiler /EHsc,/W3,/nologo,/Wp64,/Od,/Zi,/RTC1,/MTd-I"$(CUDA_INC_PATH)" -o $(ConfigurationName)\$(InputName).obj$(InputFileName)3.1.4、对所有的设定模式,均在Custom Build Step的Outputs中加入$(ConfigurationName)\$(InputName).obj。
P7.设定Outputs3.2.5、右键单击project,选择Property,再选择Linker,对所有模式修改以下设定:(1)、General/Enable Incremental Linking:No(2)、General/Additional Library Directories:$(CUDA_LIB_PATH)(3)、Input/Additional Dependencies:cudart.libP8.设定Linker参数(1)P9.设定Linker参数(2)3.2.6 设置头文件路径Tools -> Options,弹出以下对话框将右边的下拉框选择Include Files,点击添加按钮,将C:\Program Files\NVIDIA Corporation\NVIDIA CUDA SDK\common\inc选入到头文件搜索路径中。
3.2.7 选择链接库文件路径同上库头文件路径选择,将右边下拉框选择Library File,选择路径C:\ProgramFiles\NVIDIA Corporation\NVIDIA CUDA SDK\common\lib。
3.2.8、完成,可以编写cuda程序,并直接编译执行了(编译方式于C++相同)总结:这种方法不需要借助模板,也不需要使用第三方的软件。
但是这种操作复杂,而且仅对配置的单个project有效。
如果重新建立一个project又要重新配置一遍。
故不推荐使用。
需要注意的是,当需要使用CUDA SDK中的动态链接库(以dll为后缀)时,将动态链接库和生成的可执行文件放在同一个路径下。
P10.完成3.3、方法三(使用CUDA_VS_Wizard执行cuda)3.3.1、解压CUDA_VS_Wizard并安装。
3.3.2、将CUDA SDK安装目录下的bin\win32文件夹下的四个文件夹(Debug, EmuDebug, Release, EmuRelease)的路径全部加入环境变量中的path变量中。
3.3.3、使用vc直接建立工程。
在工程选项里选择CUDAWinApp。
3.4.4、如果是在模拟模式下运行,需要在解决方案中右键属性,在Configuration Properities 中将Configuration 设置为Emu模式。
P14.模拟模式设置(1)P15.模拟模式设置(2)3.3.5、完成。
总结:这种方法虽然使用了第三方的工具,但只需要配置一次即可,而且配置简单,以后每次建立cuda程序都可以直接生成。