CUDA安装
- 格式:doc
- 大小:33.50 KB
- 文档页数:3
pytorch(cuda)的安装安装好之后可以进去虚拟环境,然后进去python,接着导⼊模块import torch,然后torch.cuda.get_device_capability()可以知道⾃⼰的显卡的算⼒我的cuda算⼒是3.5,⽽⼤神说pytorch1.3需要满⾜>=3.7算⼒,所以就不⽤想了!我的显卡是GeForce920m。
需要注意的是每种包(或框架)对应的python版本,对应的其它包的版本是⼀⼀对应的,需要搞清楚再来安装。
1.安装了anaconda之后先创建⼀个虚拟环境: 创建虚拟环境:conda create -n env_name list of packagename,如:conda create -n pytorch python=3.72.然后⽤nvcc -V(如果没有反应就先安装sudo apt install nvidia-cuda-toolkit)查看Linux系统的cuda是什么版本,我的cuda版本是9.1.85。
3.接着去pytorch官⽹找安装pytorch的安装命令conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=9.2 -c pytorch4.进⼊虚拟环境,安装:conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=9.2 -c pytorch注意:可以直接覆盖,不需要先卸载再安装。
1.⼀开始我是⽤conda install pytorch torchvision cudatoolkit=10.2 -c pytorch来安装,没有指定pytorch的版本,所以它会⾃动安装最新的版本(1.5.1)。
但是运算的时候出现了错误RuntimeError: CUDA error: no kernel image is available for execution on the device(运⾏时错误:CUDA 错误:没有可在设备上执⾏的内核映像),可能是安装的cuda版本和系统的cuda版本不⼀样的原因。
Ubuntu16.04上安装CUDA9.0详细教程前⾔:本篇⽂章是基于安装CUDA 9.0的经验写,CUDA9.0⽬前⽀持Ubuntu16.04和Ubuntu17.04两个版本,如下图所⽰(最下⾯的安装⽅式我们选择第⼀个,即runfile⽅式):⼤家可以先将CUDA⽂件下来,但是最好不要急于安装,⼀定要先将NVIDIA给出仔细看⼀下,然后再找⼏篇好的博客看⼀下,⼤致了解⼀下CUDA的安装过程,对安装过程中可能出现的问题要⼤致有⼀个了解,不到万不得已不要重装系统。
安装建议:1)去官⽹下载CUDA的同时,⼀定要找份相应官⽅的安装⽂档仔细阅读,尽可能按照它的步骤⼀步步⾛,不可偷懒。
同时再找⼏篇好的博客作为参考,安装之前做到胸有成⽵。
2)在安装之前⼀定要详细检查⾃⼰的电脑配置(单显卡还是双显卡)、显卡的种类是否符合CUDA的安装要求、系统是否满⾜安装要求。
3)安装过程中每进⾏⼀项操作,都尽量去检查⼀下该项操作是否操作成功。
安装过程:⼀、安装、熟悉ubuntu16.04系统安装软件之前最好对ubuntu的命令⾏有⼀些基本的了解,像sudo、cd、ls、nona、cat、chmod等等,这样能够在安装过程中省去很多不必要的⿇烦。
(推荐⼤家去百度搜⼀下莫凡Python,他有关于ubuntu命令的视频,每⼀集都很精炼,讲的很好)⼆、检查⾃⼰的电脑环境是否具备安装CUDA的条件1) 验证⾃⼰的电脑是否有⼀个可以⽀持CUDA的GPU你可以电脑的配置信息中找到显卡的具体型号,如果你是双系统,在Windows下的设备管理器中也可以查到显卡的详细信息;你也可以在ubuntu的终端中输⼊命令: $ lspci | grep -i nvidia ,会显⽰出你的NVIDIA GPU版本信息,不过不是很详细。
我的显⽰为(GeForceGT630M):01:00.0 3D controller: NVIDIA Corporation GF117M [GeForce 610M/710M/810M/820M / GT 620M/625M/630M/720M] (rev a1)然后去CUDA的查看⾃⼰的GPU版本是否在CUDA的⽀持列表中。
Win10下安装CUDA11.0...⽬录下载地址安装CUDA配置环境变量安装CUDNN验证CUDA是否安装成功安装tesorflow-gpu2.4.1安装pytorch-gpu1.7.0安装paddlepaddle-gpu2.0.0下载地址官⽅下载:和.安装之前,建议关掉360安全卫⼠双击cuda_11.0.3_451.82_win10.exe⽂件根据⾃⼰需要更改安装路径将Visual Studio Integration的勾去掉配置环境变量C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\libnvvp;安装CUDNN将下载的CUDNN解压缩,如下图。
将将CUDNN⽂件夹⾥⾯的bin、include、lib⽂件直接复制到CUDA的安装⽬录,如下图为CUDA的安装位置,粘贴过来直接覆盖即可。
# CUDA的安装⽬录C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0等待复制完成,即可!验证CUDA是否安装成功打开cmd,输⼊如下命令,即可!nvcc -V安装tesorflow-gpu2.4.1查看对应版本pip install -i https:///simple tensorflow-gpu==2.4.1测试代码import tensorflow as tfimport osos.environ['TF_CPP_MIN_LOG_LEVEL']='2'print(tf.__version__)a = tf.constant(1.)b = tf.constant(2.)print(a+b)print('GPU:', tf.test.is_gpu_available())安装pytorch-gpu1.7.0查看对应版本pip install torch===1.7.0+cu110 torchvision===0.8.1+cu110 torchaudio===0.7.0 -f https:///whl/torch_stable.html测试代码import torchprint(torch.__version__)print(torch.cuda.is_available())安装paddlepaddle-gpu2.0.0查看对应版本python -m pip install paddlepaddle-gpu==2.0.0.post110 -f https:///whl/stable.html测试代码import paddlepaddle.utils.run_check()到此这篇关于Win10下安装CUDA11.0+CUDNN8.0+tensorflow-gpu2.4.1+pytorch1.7.0+paddlepaddle-gpu2.0.0的⽂章就介绍到这了,更多相关tensorflow pytorch CUDA 安装内容请搜索以前的⽂章或继续浏览下⾯的相关⽂章希望⼤家以后多多⽀持!。
DU-05349-001_v9.2 | June 2018Installation 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 (8)2.4. Use a Suitable Driver Model (8)2.5. Verify the Installation (9)2.5.1. Running the Compiled Examples (9)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.2T able 2 Windows Compiler Support in CUDA 9.2x86_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 nvcc_9.2 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.2\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.2\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.2\<category>\<sample_name>or the global solution files Samples*.sln located inC:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.2CUDA 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.2\1_Utilities\bandwidthTest directory.If you elected to use the default installation location, the output is placed in CUDA Samples\v9.2\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.2.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.2.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.2 Runtime" template will configure your project for use with the CUDA 9.2 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.2\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-2018 NVIDIA Corporation. All rights reserved.。
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进行并行计算了。
Windows下安装CUDA8.0在Win10下安装CUDA8.0,并使⽤VS2013测试;机器配置:Windows 10VS 2013CUDA8.0CUDA 8.0:CUDA其他版本:1. 安装CUDA 8.0双击安装下载的.exe⽂件,然后选择解压路径,如下图,解压到哪⾥⽆所谓,安装成功会⾃动删除;解压完成后,得到如下图:精简:安装所有CUDA模块,并覆盖掉当前的NVIDIA驱动程序;(说实话,容易出问题)⾃定义:选择⾃⼰想要安装的模块,此处选择这⾥;选择⾃定义后,出现下图所⽰:下⾯⼏个模块准确具体有什么⽤,不能100%确定,但能⼤概才出来:CUDA:这个是必须的,下⾯有CUDA Runntime、Samples⼀些东西;NVIDIA GeForce Experience:这个好像是为了更好的游戏体验,之前安装显卡驱动程序时也提⽰是否安装,果断拒绝了;Other components:这⾥的PhysX好像也是为了游戏体验来的;Driver components:这个就要慎重了,意思就是重新安装显卡驱动程序;如果之前已经成功安装驱动程序,这⾥就不⽤选了;如果之前没安装驱动程序,建议还是去官⽹上单独下载驱动程序进⾏安装吧;选择好需要安装的模块,就要选择安装路径了,我的选择如下图:在如图所⽰位置建⽴相应⽂件夹,然后再指定安装路径;安装成功后;Ctrl+R,打开cmd:nvcc -V输出版本信息,则表明安装成功;配置环境变量将F:\CUDA\NVIDIA GPU Computing Tookit\CUDA\v8.0\lib\x64添加的系统变量的path中;2. 安装CuDNN下载对应CUDA 8.0版本的CuDNN:(如果安装的是其他版本的CUDA,注意CuDNN的版本)下载完成后,解压得到⼀个名为cuda的⽂件夹;将该⽂件夹下的⽂件复制到上⼀步安装的CUDA中;注意对应的⽂件夹;./cuda/bin/**.dll 复制到 ./NVIDIA GPU Computing Tookit/CUDA/v8.0/bin/./cuda/include/**.dll 复制到 ./NVIDIA GPU Computing Tookit/CUDA/v8.0/include/./cuda/lib/x64/**.dll 复制到 ./NVIDIA GPU Computing Tookit/CUDA/v8.0/lib/x64/安装完成;3. 测试1使⽤VS2013打开./cuda/v8.0/Samples_vs2013.sln;加载完成后,执⾏本地Windows编译,最后输出成功,见下图;4. 测试2在VS2013上配置CUDA;4.1 新建项⽬并进⾏配置1. 打开VS2013,新建空⽩项⽬,设置项⽬名称、位置信息,如下图;2. 在源⽂件添加—>新建项—>NVIDIA CUDA 8.0—>CUDA C/C++ File,命名为hello.cu,如下图;hello.cu右键—>属性—>配置属性—>常规—>项类型,配置如下图;3. 在项⽬上右键—>⽣成依赖项—>⽣成⾃定义—>选择CUDA 8.0,如下图;4. 在项⽬上右键—>属性—>常规—>配置管理器—>活动解决⽅案平台(新建)—>键⼊或选择新平台(选择x64),如下图;5. 项⽬右键—>属性—>VC++⽬录—>包含⽬录,如下图,添加;F:\CUDA\NVIDIA GPU Computing Tookit\CUDA\v8.0\include6. 项⽬右键—>属性—>VC++⽬录—>库⽬录,如下图,添加;F:\CUDA\NVIDIA GPU Computing Tookit\CUDA\v8.0\lib\x647. 项⽬右键—>属性—>链接器—>常规,如下图,添加;$(CUDA_PATH_V8_0)\lib\$(Platform)8. 项⽬右键—>属性—>链接器—>输⼊—>附加依赖项,如下图,添加;注意:不同版本的CUDA,下⾯的lib是不同的;当然,⼀个项⽬也不⼀定需要所有的lib;具体有哪些lib,位于:F:\CUDA_Dev_Doc_Sam\v8.0\lib\x64;cublas.libcublas_device.libcuda.libcudadevrt.libcudart.libcudart_static.libcudnn.libcufft.libcufftw.libcurand.libcusolver.libcusparse.libnppc.libnppi.libnppial.libnppicc.libnppicom.libnppidei.libnppif.libnppig.libnppim.libnppist.libnppisu.libnppitc.libnpps.libnvblas.libnvcuvid.libnvgraph.libnvml.libnvrtc.libOpenCL.lib4.2 编译在上⾯建的hello.cu⽂件中添加下⾯代码:// CUDA runtime 库 + CUBLAS 库#include <cuda_runtime.h>#include <cublas_v2.h>#include <device_launch_parameters.h>#include <time.h>#include <iostream># pragma warning (disable:4819)using namespace std;bool initDevice(void)int cnt, i;cudaGetDeviceCount(&cnt);if (cnt < 0){cout << "Can not find CUDA device" << endl;return false;}for (i = 0; i < cnt; i++){cudaDeviceProp porp;if (cudaGetDeviceProperties(&porp, i) == cudaSuccess){if (porp.major >= 1) {break;}}}if (i == cnt){cout << "< 1.0" << endl;}return true;}__global__ void kernel_compute(float *model, float *input, float *output){int idx_x, idx_y;idx_y = blockIdx.x;idx_x = idx_y * blockDim.x + threadIdx.x;float sum = 0;for (int i = 0; i < 9; i++){sum += input[idx_x] * model[i];}//printf("%3d %d %2.6f %2.6f\n", idx_x, idx_y, sum, input[idx_x]);output[idx_x] = sum;}/*block ---> row*/int buildMaps(float *model, float *input, float *output, int height, int width){initDevice();float *dev_m = NULL, *dev_i = NULL, *dev_o = NULL;int size = height * width;cudaMalloc((void **)&dev_m, 9 * sizeof(float));cudaMalloc((void **)&dev_i, size * sizeof(float));cudaMalloc((void **)&dev_o, size * sizeof(float));cudaMemcpy(dev_m, model, 9 * sizeof(float), cudaMemcpyHostToDevice);cudaMemcpy(dev_i, input, size * sizeof(float), cudaMemcpyHostToDevice);dim3 grid(height, 1, 1);dim3 block(width, 1, 1);kernel_compute << <grid, block >> > (dev_m, dev_i, dev_o);cudaMemcpy(output, dev_o, size * sizeof(float), cudaMemcpyDeviceToHost); return 0;}新建main.cpp⽂件;#include <iostream>#include <Windows.h>#include <stdlib.h>#include <time.h>using namespace std;extern int buildMaps(float *model, float *input, float *output, int height, int width); void show(float *ptr, int height, int width, char *str){cout << str << " : " << endl;for (int h = 0; h < height; h++){for (int w = 0; w < width; w++){int cnt = h * width + w;printf("%5.5f ", ptr[cnt]);}cout << endl;}}#define width 5#define size (width * width)int main(){float *model = (float *)malloc(9 * sizeof(float));float *input = (float *)malloc(size * sizeof(float));float *output = (float *)malloc(size * sizeof(float));if (!model || !input || !output){std::cout << "Malloc Error" << endl;exit(-1);for (int i = 0; i < 9; i++){model[i] = (float)(i);}srand((unsigned)time(0));for (long long int i = 0; i < size; i++){input[i] = ((rand() % 100) * 1.f) / (rand() % 100 + 1);}buildMaps((float *)model, (float *)input, output, width, width); show(model, 3, 3, "model");show(input, width, width, "input");show(output, width, width, "output");int a;cin >> a;}编译,输出结果为:。
Ubuntu20.04安装cuda10.1的步骤(图⽂教程)安装前准备CUDA的主要⽤途是深度学习,⽽⽬前主流的深度学习框架Tensorflow2最⾼⽀持CUDA 10.1,因此本⽂讲解在Ubuntu 20.04系统上安装CUDA 10.1的主要过程。
⾸先要查看你的NVIDIA显卡驱动是否⽀持cuda10.1版本。
在终端执⾏以下命令:nvidia-smi如果 CUDA Version: … 这⾥的版本号⼤于等于10.1(我的是10.2),就可以安装cuda10.1.关键点:gcc降级因为Ubuntu20.04⾃带的gcc版本为9.3,⽽cuda10.1不⽀持gcc-9,因此要⼿动安装gcc-7,命令如下:sudo apt-get install gcc-7 g++-7安装完gcc-7,系统中就存在两个版本的gcc,因此要设置默认的gcc,命令如下:sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 9sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 1此命令可以通过update-alternatives设置gcc各版本的优先级,优先级最⾼的为系统默认版本,可以⽤下述命令显⽰其优先级:sudo update-alternatives --display gcc设置默认的g++也是如此:sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 9sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 1显⽰g++优先级:sudo update-alternatives --display g++按照官⽹的安装步骤下载并安装CUDA 10.1如上图所⽰,推荐选择run⽂件安装,⽐较简洁。
最详细不过的CUDA的下载安装使⽤、环境变量配置,有这⼀篇就够了在上⼀期中,我们介绍了为什么使⽤GPU可以加速计算和处理图像,以及查看⾃⼰的电脑能否使⽤GPU加速,不知道的可以去看上⼀期⽂章,这期我们正式的来下载与安装GPU加速⼯具CUDA,并检查是否安装成功。
前⾔:可以看到,如果我们想要下载安装CUDA需要有NVIDA的显卡、Windows系统、Visual Studio,即:第⼀步:查看⾃⼰电脑是否有NVIDA显卡。
第⼆步:查看⾃⼰是否有⽀持的版本的微软Windows系统,具体⼤家可看上图Table1。
第三步:查看⾃⼰是否有⽀持版本的Visual Studio,因为我们在安装CUDA时需要⽤到其中的组件,具体请看上图Table2。
安装⼯作总结查看⾃⼰有是否有⽀持NVIDA的独⽴显卡查看⾃⼰是否有NVIDA显卡驱动程序,没有请下载安装官⽹下载安装 Microsoft Visual Studio(申请⼀个微软账号)官⽹下载安装 CUDA检验CUDA安装是否成功CUDA安装成功后的使⽤这⾥教⼤家安装CUDA10.2和免费社区版VS2017的下载和安装教程正式下载与安装CUDA第⼀步:查看⾃⼰是否有⽀持安装CUDA的NVIDA显卡,具体请见我上期⽂章。
安装完后,可以打开NVIDA控制⾯板,查看GPU显卡所⽀持的CUDA版本,具体开始菜单 -》NVIDIA控制⾯板-》帮助-》系统信息-》组件-》nvidia.dll后⾯的cuda参数,可以看到,我的显卡⽀持版本为10.2,所以我下载安装cuda10.2版本。
第三步:下载安装 Visual Studio安装Visual Studio,因为CUDA在安装时,需要VS的⾥⾯的⼯具包来编译。
VS这⾥我安装的是社区免费版VS2017,⽆需秘钥key就可以使⽤,也可以使⽤其它版本,但是需要key,请见第⼀张图的Table2,在安装过程中,会⾃动检测本机是否已经安装了配套的VS版本其中之⼀,如果VS版本和Cuda版本不匹配的话,安装⽆法进⾏。
cuda安装失败解决方法随着计算资源的快速发展,越来越多的开发者希望利用GPU来实现软件的加速运行,其中一种最常用的GPU加速软件是Nvidia的CUDA。
然而,由于CUDA的安装过程比较复杂,它的安装过程也容易出现问题。
本文就介绍了CUDA安装失败的解决方法,以便开发者能够成功安装CUDA。
首先,在开始安装CUDA之前,需要确认一些基本的硬件信息,比如显卡的型号、显卡的内存大小、系统的位数等。
此外,还需要确认的是,用户的电脑是否已经安装了NVIDIA显卡驱动,如果还没有安装,那么应该先安装显卡驱动,然后再安装CUDA。
其次,在安装CUDA之前,还需要确认用户的电脑是否已经安装了支持CUDA的编译器,如GCC、Visual Studio等。
有了这些编译器,开发者才能够将CUDA编译成可运行文件。
三,需要确认用户的电脑是否安装了CUDA的相关依赖文件,如CUDA Toolkit、CUDA Driver、CUDA Samples等。
这些依赖文件可以免费从NVIDIA的官方网站下载。
四,在正式安装CUDA之前,还需要确认用户的电脑是否安装了相关的硬件驱动,如NVIDIA显卡驱动程序、USB驱动程序、硬件诊断工具等。
如果这些驱动程序没有安装,可能会导致CUDA的安装失败。
最后,在安装CUDA之前,还需要确认用户的电脑是否已经配置了CUDA的环境变量,包括系统变量、用户变量等。
如果这些变量没有设置正确,也可能会导致CUDA的安装失败。
总之,CUDA的安装过程比较复杂,需要用户确认一些基本的硬件信息、安装相关的编译器、安装相关的依赖文件、安装相关的硬件驱动程序以及配置CUDA的环境变量等。
只有完成了以上步骤,才能够成功安装CUDA。
cuda、cudnn下载安装教程cuda、cudnn下载安装教程
安装环境:
l 操作系统:win10
l python版本:3.8
l NVIDIA显卡驱动版本:432.0
l CUDA:10.1
l cudnn:8.0.3
注意CUDA、cudnn、 NVIDIA显卡驱动版本之间的匹配
⼀般⽽⾔,不同版本的CUDA要求不同的NVIDIA驱动版本,同时显卡驱动版本要不低于CUDA的安装版本,官⽅的版本对应要求说明:
具体的对照关系如下:
⼀、 cuda
1.1 cuda下载
下载地址:
如图:
双击击应⽤程序
安装cuda时,第⼀次会让设置临时解压⽬录,第⼆次会让设置安装⽬录;
临时解压路径,建议默认即可,也可以⾃定义。
安装结束后,临时解压⽂件夹会⾃动删除;
⼀路默认就可
添加cuda环境变量(控制⾯板—系统和安全—系统—⾼级系统设置---环境变量)
⼆、 cudnn
2.1 cudnn下载
下载地址:
注:需要注册登录才能下载
如图:
2.2 cudnn安装
解压⽂件夹,将解压后的⽂件夹下的⽂件拷贝到cuda安装⽬录与之相对应的⽂件夹下。
完⼯!!。
linuxCUDA安装
⾸先是安装依赖库
sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
然后从NVIDIA developer官⽹下载CUDA驱动
添加执⾏权限并安装
chmod a+x cuda_9.0.28_linux.run
sudo ./cuda_9.0.28_linux.run
这⼀步在安装时,请注意不要安装driver,我们之前已经安装过driver了,如果选择yes,会出错
环境变量的配置,这⾥主要配置/etc/profile⽂件和/etc/ld.so.conf.d/cuda.conf⽂件,⽽cuda.conf⽂件需要新建在etc/profile⽂件中添加PATH的路径
PATH=/usr/local/cuda/bin:$PATH
export PATH
cuda.conf⽂件
/usr/local/cuda/lib64
使环境变量⽣效
source /etc/profile
sudo ldconfig
这⼀步进⾏完成后,可以通过nvcc --version等命令来检查CUDA是否正确安装
编译CUDA samples
切换到samples⽬录,使⽤make即可正确编译,如果出错,请按照正确信息进⾏排错
编译完成后,samples⽬录下就出现了⼀个bin⽂件夹,切换⽂件夹
cd ./bin/x86_64/linux/release
即可运⾏下边的实例。
CUDA 在linux系统上安裝指南适用的操作系统Fedora 7,8,9,10Redhat Enterprise 3.x,4.x,5.xSUSE Linux Enterprise Desktop 10-SP1,10.2,11.0OpenSUSE 10.1,10.2,10.3,11.0,11.1Ubuntu 7.04 ,7.10.,8.04,8.10,9.04-------------------------------------------------------------------------------- 下载和操作系统配套的驱动程序,SDK, tookit地址:/object/cuda_get.html--------------------------------------------------------------------------------安装程序(TESLA 搭配非NVIDIA 显卡使用,可不须安装该显卡驱动程序)--------------------------------------------------------------------------------在Terminal中安装(不要进XWindow )以linux as5.2下安装cuda2.1为例1.安装CUDA 运算驱动程序命令行下执行: sh NVIDIA-Linux-x86_64-180.22-pkg2.run根据提示回车执行各步安装过程关于如何安装NVIDIA 的Linux 驱动程序,请参考NVIDIA Accelerated Linux Driver Set README and Installation Guide/XFree86/Linux-x86/1.0-9755/README/index.html 安装完毕可以在Terminal中执行[nvidia-xconfig -query-gpu-info]以查看所安装的NVIDIA GPU执行结果请见下图2.安装NVIDIA CUDA Toolki t命令行下执行:sh cudatoolkit_2.1_linux64_rhel5.2.run安装程序会要求你输入安装路径或是接受默认值,推荐以root 身份安装并使用默认路径(/usr/local) ,在之后我们将会以<CUDA_INSTALL_PATH>来代替实际的安装路径增加CUDA 二进制文件(nvcc)及函数路径(libcuda.so)到PATH 及LD_LIBRARY_PATH 的环境变量安装完毕可以执行[nvidia-smi]以查看所安装的CUDA GPU[nvidia-smi]是NVIDIA 提供可以让我们确认安装在机器中的GPU 是否都能正常运行CUDA 的新工具执行结果请见下图3.安装NVIDIA CUDA SDK命令行下执行:sh cuda-sdk-linux-2.10.1215.2015-3233425.run安装程序会要求输入安装路径或是接受默认值,默认安装路径为用户的家目录(/NVIDIA_CUDA_SDK)。
Ubuntu16安装CUDA(9.1)和cuDNN的实现步骤(图⽂)⽬录本篇概览特别问题说明准备⼯作下载和安装Nvidia驱动安装CUDA安装cuDNN本篇概览⾃⼰有⼀台2015年的联想笔记本,显卡是GTX950M,已安装ubuntu 16.04 LTS桌⾯版,为了使⽤其GPU完成deeplearning4j的训练⼯作,⾃⼰动⼿安装了CUDA和cuDNN,在此将整个过程记录下来,以备将来参考,整个安装过程分为以下⼏步:准备⼯作安装Nvidia驱动安装CUDA安装cuDNN特别问题说明按照⼀般步骤,在安装完Nvidia显卡驱动后,会提⽰对应的CUDA版本,接下来按照提⽰的版本安装CUDA,例如我这⾥提⽰的是11.2,正常情况下,我应该安装11.2版本的CUDA 但是我选择9.1版本就⾏安装,因为之前的开发中发现deeplearning4j使⽤了11.2的SDK后,启动应⽤会有ClassNotFound的错误,此问题⾄今未修复(惭愧,欣宸⽔平如此之低…),因此,我在Nvidia驱动提⽰11.2版本的情况下,依然安装了9.1版本,后来在此环境运⾏deeplearning4j应⽤⼀切正常如果您没有我这类问题,完全可以按照驱动指定的版本来安装CUDA,具体的操作步骤稍后会详细说到;准备⼯作接下来的操作,除了在⽹页下载,其余都是ssh远程连接到ubuntu机器操作的,ssh登录的帐号为普通帐号,并⾮root如果已有驱动,请先删除sudo apt-get remove --purge nvidia*禁⽤nouveau驱动(很重要),⽤vi打开⽂件/etc/modprobe.d/blacklist.conf,在尾部增加以下内容,然后保存退出:blacklist nouveaublacklist lbm-nouveauoptions nouveau modeset=0alias nouveau offalias lbm-nouveau off关闭nouveau:echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf更新initramfs:update-initramfs -u执⾏reboot重启电脑重启后,执⾏以下命令,应该不会有任何输出,证明nouveau已经禁⽤:lsmod|grep nouveau获取Kernel source:sudo apt-get install linux-source安装过程中显⽰信息如下图:根据上图红框中的信息,可知内核版本号为,于是执⾏以下命令:sudo apt-get install linux-headers-4.4.0-210-generic下载和安装Nvidia驱动点击上图搜索按钮后,进⼊下图页⾯,点击下载:下载得到的⽂件名为NVIDIA-Linux-x86_64-460.84.run关闭图形页⾯:sudo service lightdm stop给驱动⽂件增加可执⾏权限:sudo chmod a+x NVIDIA-Linux-x86_64-460.84.run开始安装:sudo ./NVIDIA-Linux-x86_64-460.84.run -no-x-check -no-nouveau-check -no-opengl-files遇到下图,选择红框:遇到下图,直接回车:恢复图形页⾯:sudo service lightdm start执⾏命令nvidia-smi,如果驱动安装成功,会显⽰以下内容:will@lenovo:~/temp/202106/20$ nvidia-smiSun Jun 20 09:02:11 2021+-----------------------------------------------------------------------------+| NVIDIA-SMI 460.84 Driver Version: 460.84 CUDA Version: 11.2 ||-------------------------------+----------------------+----------------------+| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC || Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. || | | MIG M. ||===============================+======================+======================|| 0 GeForce GTX 950M Off | 00000000:01:00.0 Off | N/A || N/A 41C P0 N/A / N/A | 0MiB / 4046MiB | 1% Default || | | N/A |+-------------------------------+----------------------+----------------------++-----------------------------------------------------------------------------+| Processes: || GPU GI CI PID Type Process name GPU Memory || ID ID Usage ||=============================================================================|| No running processes found |+-----------------------------------------------------------------------------+从上述内容可见CUDA Version: 11.2表⽰该驱动对应的CUDA版本应该是11.2,正如前⾯所说,我这边遇到了问题,因此接下来会安装9.1版本,但是您可以选择安装11.2安装CUDA如下图,下载Linux版本:继续选择x86_64:选择具体的Linux版本及其版本号:要下载的东西不少,⼀个安装程序和三个补丁:上述四个⽂件的下载地址整理如下:下载完毕后,执⾏命令chmod a+x *.run为上述四个⽂件增加可执⾏权限安装CUDA:sudo sh cuda_9.1.85_387.26_linux.run遇到license时,像是⽤vi⼯具那样,输⼊":",再输⼊"q"回车,就能跳过license阅读,执⾏真正的安装操作了:接下来是⼀系列提问,每⼀个提问的回答如下图,千万注意红框中的问题⼀定要选择n:安装完成后输出以下内容:Installing the CUDA Toolkit in /usr/local/cuda-9.1 ...Missing recommended library: libGLU.soMissing recommended library: libX11.soMissing recommended library: libXi.soMissing recommended library: libXmu.soMissing recommended library: libGL.soInstalling the CUDA Samples in /home/will ...Copying samples to /home/will/NVIDIA_CUDA-9.1_Samples now...Finished copying samples.============ Summary ============Driver: Not SelectedToolkit: Installed in /usr/local/cuda-9.1Samples: Installed in /home/will, but missing recommended librariesPlease make sure that- PATH includes /usr/local/cuda-9.1/bin- LD_LIBRARY_PATH includes /usr/local/cuda-9.1/lib64, or, add /usr/local/cuda-9.1/lib64 to /etc/ld.so.conf and run ldconfig as rootTo uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-9.1/binPlease see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-9.1/doc/pdf for detailed information on setting up CUDA.***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 384.00 is required for CUDA 9.1 functionality to work. To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:sudo <CudaInstaller>.run -silent -driverLogfile is /tmp/cuda_install_13425.log打开⽂件~/.bashrc,在尾部增加以下两⾏(LD_LIBRARY_PATH如果已经存在,请参考PATH的写法改成追加):export PATH=/usr/local/cuda-9.1/bin:$PATHexport LD_LIBRARY_PATH=/usr/local/cuda-9.1/lib64执⾏命令source ~/.bashrc使配置⽣效执⾏命令su -切换到root帐号,执⾏以下命令(不要⽤sudo,⽽是切到root帐号):sudo echo "/usr/local/cuda-9.1/lib64" >> /etc/ld.so.conf再以root⾝份执⾏以下命令:ldconfig执⾏命令exit退出root⾝份,现在⼜是普通帐号的⾝份了执⾏命令nvcc -V检查CUDA版本,注意参数V是⼤写:will@lenovo:~$ nvcc -Vnvcc: NVIDIA (R) Cuda compiler driverCopyright (c) 2005-2017 NVIDIA CorporationBuilt on Fri_Nov__3_21:07:56_CDT_2017Cuda compilation tools, release 9.1, V9.1.85安装第⼀个补丁:sudo sh cuda_9.1.85.1_linux.run安装第⼆个补丁:sudo sh cuda_9.1.85_387.26_linux.run安装第三个补丁:sudo sh cuda_9.1.85_387.26_linux.run安装cuDNN按提⽰登录,如果没有帐号请注册⼀个,登录后进⼊下载页⾯,需要点击下图红框位置才有能见到⽼版本:选择与CUDA匹配的版本:下载后解压,得到⽂件夹cuda,然后执⾏以下命令:sudo cp cuda/include/cudnn.h /usr/local/cuda/include/sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/sudo chmod a+r /usr/local/cuda/include/cudnn.hsudo chmod a+r /usr/local/cuda/lib64/libcudnn*执⾏检查确认的命令cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2,如果安装顺利会有以下输出:#define CUDNN_MAJOR 7#define CUDNN_MINOR 1#define CUDNN_PATCHLEVEL 3--#define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)#include "driver_types.h"⾄此,Ubuntu16安装CUDA(9.1)和cuDNN已经完成了,希望能给您⼀些参考。
一、安装硬件环境: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和driver。
安装cuda(这里全部按默认路径。
在网上下载最新版本的)2.1 安装 CUDA driver对于没有安装NV显卡的计算机,不需要安装driver安装包,程序也可以在模拟模式下运行。
2.2 安装cuda toolkit双击NVIDIA_CUDA_toolkit_4.0.17_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中。
Ubuntu20.04CUDAcuDNN安装⽅法(图⽂教程)CUDA安装下载cuda输⼊nvidia-smi命令查看⽀持的cuda版本如果⽆法查看,则说明尚未安装nvidia驱动,点击附加驱动,选择对应版本的驱动即可⾃动下载。
Ubuntu20.04⾃带的gcc版本为9.7.0,需要添加gcc7才可安装cuda10.2,输⼊命令安装gcc7apt-get install gcc-7 g++-7查看gcc版本,可以看到⽬前系统中存在7和9两个版本使⽤update-alternatives进⾏版本切换,输⼊以下命令:sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 100sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 50此时输⼊sudo update-alternatives --config gcc命令查看gcc的默认版本,可以看到当前默认gcc版本为7,即切换成功。
安装cuda输⼊命令进⾏安装sudo sh cuda_10.2.89_440.33.01_linux.run点击continuecuda安装包是⾃带显卡驱动的,所以这⼀步按空格去掉安装显卡驱动的选项,然后选择install配置环境变量输⼊gedit ~/.bashrc命令打开⽂件,在⽂件结尾输⼊以下语句,保存。
export PATH=/usr/local/cuda-10.2/bin${PATH:+:${PATH}}export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}更新环境变量配置source ~/.bashrc⾄此cuda安装完成,输⼊nvcc -V命令查看cuda信息安装cuDNN下载解压之后,将cuda/include/cudnn.h⽂件复制到usr/local/cuda/include⽂件夹,将cuda/lib64/下所有⽂件复制到/usr/local/cuda/lib64⽂件夹中,并添加读取权限:sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*⾄此cuDNN安装完成到此这篇关于Ubuntu 20.04 CUDA&cuDNN安装⽅法(图⽂教程)的⽂章就介绍到这了,更多相关Ubuntu20.04 CUDA&cuDNN安装内容请搜索以前的⽂章或继续浏览下⾯的相关⽂章希望⼤家以后多多⽀持!。
centos安装cuda零修订记录序号修订内容修订时间1新增2021/1/20⼀摘要本⽂主要介绍centos 8.1 安装cuda⼆环境信息(⼀) 操作系统[root@ussuritest004 ~]# cat /etc/centos-releaseCentOS Linux release 8.1.1911 (Core)[root@ussuritest004 ~]#(⼆) cuda 版本我这⾥⽤的是cuda_10.2.89_440.33.01_linux.run三实施(⼀)准备⼯作3.1.1 检查机器是否装有⽀持cuda的gpu[root@ussuritest004 software]# lspci | grep -i nvidiaaf:00.0 3D controller: NVIDIA Corporation TU104GL [Tesla T4] (rev a1)[root@ussuritest004 software]#3.1.2 下载此处先略(⼆) runfile 安装3.2.1 安装基础依赖[root@ussuritest004 yum.repos.d]# yum install gcc这个可以不要[root@ussuritest004 yum.repos.d]# yum install libglu1-mesa libxi-dev libxmu-dev libglu1-mesa-dev freeglut3-dev3.2.2 关闭 the Nouveau drivers3.2.2.1 检查nouveau 驱动是否启动[root@ussuritest004 log]# lsmod | grep nouveaunouveau 2215936 1mxm_wmi 16384 1 nouveauvideo 45056 1 nouveauwmi 32768 2 mxm_wmi,nouveaui2c_algo_bit 16384 2 ast,nouveaudrm_kms_helper 217088 2 ast,nouveauttm 110592 2 ast,nouveaudrm 524288 7 drm_kms_helper,ast,ttm,nouveau[root@ussuritest004 log]#有输出表⽰启动了。
Ubuntu18.04安装CUDA10.2+cuDNN 1 安装CUDA10.2下载CUDA:,选择CUDA Toolkit 10.2版本选择操作系统、架构、Distribution及其版本(这⾥是Ubuntu18.04)和runfile(local)⽂件格式可以使⽤wget下载,亦可复制链接进⾏下载下载完成后:sudo sh cuda_10.2.89_440.33.01_linux.run步骤说明:(1)Do you accept the above EULA? accept(2)CUDA Installer 取消Driver安装(Enter选择/取消)-> Install(3)⽇志配置环境变量:vim ~/.bashrc添加:export PATH=/usr/local/cuda-10.2/bin:$PATHexport LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64:$LD_LIBRARY_PATH⽣效:source ~/.bashrc验证:cd /usr/local/cuda-10.2/samples/1_Utilities/deviceQuerysudo make./deviceQuery出现如下输出,则CUDA安装成功或nvcc -V出现如下输出,则CUDA安装成功。
2 安装cuDNN下载cuDNN:(需注册)选择:I Agree To the Terms of the cuDNN Software License Agreement -> Archived cuDNN Releases选择适配Ubuntu、CUDA 10.2的最新版cuDNN v8.2.2 -> cuDNN Library for Linux (x86)下载完成后,解压,进⼊相应⽬录,运⾏以下命令:sudo cp cuda/include/cudnn.h /usr/local/cuda-10.2/includesudo cp cuda/include/cudnn_version.h /usr/local/cuda-10.2/includesudo cp cuda/lib64/libcudnn* /usr/local/cuda-10.2/lib64sudo chmod a+r /usr/local/cuda-10.2/include/cudnn.hsudo chmod a+r /usr/local/cuda-10.2/include/cudnn_version.hsudo chmod a+r /usr/local/cuda-10.2/lib64/libcudnn*验证:cat /usr/local/cuda-10.2/include/cudnn_version.h | grep CUDNN_MAJOR -A 2。
CUDA3.1 X32 + Windows 7 32bit + Visual Studio 2005 +
Visual assist安装指南收藏
1. 安装CUDA Driver,toolkit,SDK
a) 建议driver,toolkit,SDK的顺序,默认路径安装
b) 如果笔记本用户,可以选择强行安装3.1的驱动包(选择对应台式机的型号),但是会有部分游戏随机花屏等问题。
可以装2.2就有笔记本驱动
2. 安装Visual studio 2005
3. 安装wizard x32版
4. 环境配置
a) 将
i. C:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\bin\win32\Debug;
ii. C:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\bin\win32\emudebug;
iii. C:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\bin\win32\release;
添加到path中
b) 打开vs2005,工具,选项,项目和解决方案,VC++目录,
库文件中添加
C:\Documents and Settings\All Users\Application Data\NVIDIA
Corporation\NVIDIA GPU Computing SDK\C\common\lib
C:\CUDA\lib
包含文件中添加
C:\CUDA\include
C:\Documents and Settings\All Users\Application Data\NVIDIA
Corporation\NVIDIA GPU Computing SDK\C\common\inc
源文件中添加
C:\Documents and Settings\All Users\Application Data\NVIDIA
Corporation\NVIDIA GPU Computing SDK\C\common\src
c) VC++项目设置,
d) C/C++扩展名添加*.cu
e) 包含扩展名添加.cuh
f) 规则文件搜索路径设为
C:\Documents and Settings\All Users\Application Data\NVIDIA
Corporation\NVIDIA GPU Computing SDK\C\common
g) 到此可以新建一个项目测试一下hello cuda能否运行。
h) 调试程序时
在工程上右键选custom build rules->Find Existing,选中cuda.rules,点击ok。
在工程上右键选属性,在CUDA中
GPU Architecture选择sm_13
Use Fast Math 选择“是”
Optimization选择Maximize speed或Full Optimization
Set the default "CUDA -> Advanced -> GPU Architecture Compile Name" as "1.0(virtual) Arch", You may change it depends on your system.
Set the default "CUDA -> Advanced -> GPU Architecture Code Name" as "1.0(hardware) code", You may change it depends on your system.
Set the default "CUDA -> Output -> Inern Mode" as "Real" in Debug & Release;
5. 安装Visual Assist
破解版一大堆自己找吧
6. VA配置
a) 将C:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\NVIDIA GPU Computing
SDK\C\doc\syntax_highlighting\visual_studio_8中的usertype.dat拷贝到
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE中
b) 打开VS2005,选择工具-选项-文本编辑器-文件扩展名,在扩展名编辑框中填入cu,在编辑器下拉菜单中选择Microsoft Visual C++,单击添加,然后点击确定。
c) 打开注册表,在HKEY_LOCAL_MACHINE\SOFTWARE
\Microsoft\VisualStudio\9.0\Languages\File Extensions\.cpp下面添加子键 .cu 然后copy .cpp的键值到.cu。
这样才能表示cu也是VS下的VC的工程文件。
d) 打开VS,运行下VA(建立一个CPP工程,折腾到VA能用为止),关掉IDE,否则注册表不会添加对应信息。
e) HKEY_CURRENT_USER\Software\Whole Tomato\Visual Assist X\VANet8 在ExtSource键添加键值.cu
f) 打开Visual Assist属性,在projects 的C/C++ Directories custom下面添加CUDA 的头文件目录,这样才能在Visual Assist 生成规则的时候找到CUDA自身的特殊定义才能生成Visual Assist的关键字,如__global__.
添加的目录有C:\CUDA\include,C:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\common\inc
Source file中添加C:\Documents and Settings\All Users\Application
Data\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\common\src。