GPU和CPU区别

1,CPU主要用于处理通用逻辑,以及各种中断事物

2,GPU主要用于计算密集型程序,可并行运作;

NVIDIA 的 GeForce 显示卡系列采用 GPU 特性进行快速计算,渲染电脑画面,比如大型游戏,图像处理等场景的画面
深度学习的训练过程中,包含了大量重复性的计算,利用 GPU 的计算和并行特性,可提高训练的效率,具备 GPU 特性的电脑显卡就有用武之地啦!

使用 GPU 的计算前需要做些准备,下面以 window 7 x64 系统为例子

一,检查显卡类型和计算能力
1,查看笔记本显卡型号,以及计算能力
下载个 GPU 查看器, https://www.techpowerup.com/download/gpu-z/

我笔记本显卡型号:NVIDIA GeForce 940M

2,确定对应显卡 GPU 的计算能力
去 NVIDIA 官网查看 https://developer.nvidia.com/cuda-gpus

NVIDIA GeForce 940M Compute Capability 是 5.0

tensorflow 1.3 版本要求 GPU 计算能力必须在 3.0 以上
https://www.tensorflow.org/versions/r1.3/install/install_windows

GPU card with CUDA Compute Capability 3.0 or higher. See NVIDIA documentation for a list of supported GPU cards.

要是计算能力不支持,运行 tensorflow 会报错

Ignoring visible gpu device (device: 0, name: GeForce GT 630M, pci bus id: 0000:01:00.0) with Cuda compute capability 2.1. The minimum required Cuda capability is 3.0.

二,安装显卡驱动, CUDA ,cuDNN

1,安装显卡驱动

显卡一般都安装好了,但可能会出现显卡驱动版本跟 CUDA 不对应的问题
自己去 NVIDIA 官网下载驱动http://www.nvidia.com/Download/index.aspx,或者使用驱动精灵

2,安装 CUDA
CUDA的主要作用是链接 GPU 和 应用程序,方便用户通过 CUDA 的 API 调度 GPU 进行计算

安装说明地址:http://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/
选择对应版本,window7 系统 64 位, tensorflow 1.3 当前使用 CUDA 8.0版本

安装 cuda 的时候,会询问是否安装显卡驱动,说明 cuda 安装程序里包含了的显卡驱动;
建议先不要安装 cuda 里的显卡驱动,待安装完 cuda 后,执行例子程序,如果报错再检查显卡驱动是否正确,避免覆盖原来的显卡驱动

安装完后执行 nvcc -V 检查

C:\Users\yunhuichen>nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Mon_Jan__9_17:32:33_CST_2017
Cuda compilation tools, release 8.0, V8.0.60

运行例子

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\extras\demo_suite>device
Query.exe
deviceQuery.exe Starting... CUDA Device Query (Runtime API) version (CUDART static linking) Detected 1 CUDA Capable device(s) Device 0: "GeForce 940M"
CUDA Driver Version / Runtime Version 9.0 / 8.0
CUDA Capability Major/Minor version number: 5.0
Total amount of global memory: 1024 MBytes (1073741824 bytes)
( 3) Multiprocessors, (128) CUDA Cores/MP: 384 CUDA Cores
GPU Max Clock rate: 980 MHz (0.98 GHz)
Memory Clock rate: 1001 Mhz
Memory Bus Width: 64-bit
L2 Cache Size: 1048576 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(65536), 2D=(65536, 65536),
3D=(4096, 4096, 4096)
Maximum Layered 1D Texture Size, (num) layers 1D=(16384), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(16384, 16384), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 2048
Maximum number of threads per block: 1024
Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535)
Maximum memory pitch: 2147483647 bytes
Texture alignment: 512 bytes
Concurrent copy and kernel execution: Yes with 1 copy engine(s)
Run time limit on kernels: Yes
Integrated GPU sharing Host Memory: No
Support host page-locked memory mapping: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support: Disabled
CUDA Device Driver Mode (TCC or WDDM): WDDM (Windows Display Driver Mo
del)
Device supports Unified Addressing (UVA): Yes
Device PCI Domain ID / Bus ID / location ID: 0 / 4 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() with device simu ltaneously) > deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 9.0, CUDA Runtime Versi
on = 8.0, NumDevs = 1, Device0 = GeForce 940M
Result = PASS C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\extras\demo_suite>

至此已经安装 cuda 成功
当然此过程可能会遇到以下问题

NVIDIA Geforce GTX 940M 设备是不可移动的,无法弹出或拔出

这是因为显卡驱动和CUDA版本不对应,可试下安装CUDA里的显卡驱动

3,安装 cuDNN
cuDNN 是一个为了优化深度学习计算的类库,它能将模型训练的计算优化之后,再通过 CUDA 调用 GPU 进行运算
当然你也可直接使用 GUDA,而不通过 cuDNN ,但运算效率会低好多

cuDNN 下载地址:https://developer.nvidia.com/cudnn

选择跟CUDA 8.0 对应的版本 cuDNN  6.1

其实就几个 lib 文件,解压出来把安装路径添加到 PATH 中;你也可以把所有 lib 文件复制到 CUDA 对应目录下

安装CUDA和cuDNN的更多相关文章

  1. 记录下自己安装cuda以及cudnn

    之前已经装过一次了,不过没有做记录,现在又要翻一堆博客安装,长点记性,自己记录下. 环境 ubuntu16.04 python2.7 商家送过来时候已经装好了显卡驱动,所以省去了一大麻烦. 剩下的就是 ...

  2. win10 安装cuda和cudnn

    首先通过nvidia-smi 查看自己的显卡驱动对应的cuda版本. 参考:https://blog.csdn.net/qq_40212975/article/details/89963016 再去官 ...

  3. Ubuntu安装CUDA、CUDNN比较有用的网址总结

    Ubuntu安装CUDA.CUDNN比较有用的网址总结 1.tensorflow各个版本所对应的的系统要求和CUDA\CUDNN适配版本 https://tensorflow.google.cn/in ...

  4. 非root用户安装cuda和cudnn

    1.根据自己的系统在官网下载cuda (选择runfile(local)) https://developer.nvidia.com/cuda-downloads 2.进入下载目录,并执行 sh cu ...

  5. Anaconda--在虚拟环境中安装CUDA and cudnn

    在conda虚拟环境中安装CUDAconda install cudatoolkit=8.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs ...

  6. ubuntu 安装 CUDA、 cuDNN 的tips

    CUDA 查看驱动兼容性:https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html 查看GCC 与CUDA 驱动版本的兼容性 ...

  7. 【tf.keras】Linux 非 root 用户安装 CUDA 和 cuDNN

    TensorFlow 2.0 for Linux 使用时报错:(cuDNN 版本低了) E tensorflow/stream_executor/cuda/cuda_dnn.cc:319] Loade ...

  8. ubuntu安装cuda、cudnn

    环境: Ubuntu 16.04.4 LTS CUDA:8.0 CUDNN:5.1 CUDA下载:https://developer.nvidia.com/cuda-80-ga2-download-a ...

  9. Windows10 安装 CUDA + cuDNN + pyTorch

    2020/5/29 在 windows10 上面安装 CUDA 和 cuDNN 0.简单了解一下 CUDA 和 cuDNN 1)什么是 CUDA CUDA(ComputeUnified Device ...

随机推荐

  1. js如何实现动态点击改变单元格颜色?

    js如何实现动态点击改变单元格颜色? 一.总结 1.通过table的rows属性,遍历表格所有行,然后通过cells属性,遍历每一行中的单元格. 2.遍历的过程中,动态的为每一个单元格定义单击事件,改 ...

  2. 毕设二:python 爬取京东的商品评论

    # -*- coding: utf-8 -*- # @author: Tele # @Time : 2019/04/14 下午 3:48 # 多线程版 import time import reque ...

  3. NSUserDefaults:通常用来保存一些小巧的数据,如用户的用户名密码,或者是用户的使用习惯,如是否自动打开背景音乐等。

    1,NSUserDefaults通常用来保存一些小巧的数据,如用户的用户名密码,或者是用户的使用习惯,如是否自动打开背景音乐等. 2,使用它的原因就是:代码简短,使用方便 3,使用方法如下: -(vo ...

  4. app.config中的值获取及设置 以及对log4net配置

      修改或新增AppSetting节点 /// <summary> /// 修改AppSettings中配置 /// </summary> /// <param name ...

  5. hello.c内核模块编译 -- linux内核

    Linux开发模块,在本机上看调试信息的方法走通了.当前版本号2.6.32-32-generic uname –r 能够查询 这里取module_param()作为样例. 该宏被定义在include/ ...

  6. Vue Router的官方示例改造

    基于Vue Router 2018年8月的官方文档示例,改造一下,通过一个最简单的例子,解决很多初学者的一个困惑. 首先是官方文档示例代码 <!DOCTYPE html> <html ...

  7. 【Codeforces Round #438 B】Race Against Time

    [链接]h在这里写链接 [题意] 时针.分钟.秒针走不过去. 问你从t1时刻能不能走到t2时刻 [题解] 看看时针.分钟.秒针的影响就好. 看看是不是在整时的位置就好. 然后看看影响到x不能到y; 然 ...

  8. Qt5信号与槽C++11风格连接简介

    最近在论坛上看到了这个方面的问题,详见这里. 随后浅浅地学习了一下子,看到了Qt官方论坛上给出的说明,觉得C++11的functional连接方法还是比Qt4既有的宏连接方法有很大不同. 官方论坛的文 ...

  9. xml报错(dtd):The markup declarations contained or pointed to by the document type declaration must be well-formed

    文件后缀为.xml里如下一行报错“The markup declarations contained or pointed to by the document type declaration mu ...

  10. 数据集成工具:Teiid实践

    数据集成是把不同来源.格式.特点性质的数据在逻辑上或物理上有机地集中,从而为企业提供全面的数据共享.数据集成的方式多种多样,这里介绍的 Teiid 是其中的一种:通过抽象和联邦技术,实现分布式数据源的 ...