tensorflow gpu配置安装,请问gtx850m gddr3 搭配的cuda版本是多少?

温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
windows 10 64bit下安装Tensorflow+Keras+VS2015+CUDA8.0 GPU加速/p/c245d46d43f0写在前面的话 日,Google Brain 工程师团队宣布在 TensorFlow 0.12 中加入初步的 Windows 支持。但是目前只支持64位,而且Python版本为3.5版本,需要CUDA 8.0 。 之前Tensorflow对windows的支持并不好,导致如果需要使用它,需要转移到Linux平台,或者使用Cygwin什么的,总之挺麻烦,现在好了。麻烦事google帮我们解决了。感谢google! Tensorflow和Keras都是支持Python接口的,所以本文中说的都是搭建一个Python的深度学习环境。还有一点,我也是新手,写得不好请勿喷!忽视本文就好。如果你不清楚Keras和Tensorflow是什么关系?请看下图:Keras与Tensorflow和theano关系图.png Keras是对Tensorflow或者Theano的再次封装,也就是以Tensorflow或Theano为后端,默认的后端是tensorflow,如果你想使用theano为后端,可以更改为theano。Keras为什么要对tensorflow和theano进行再次封装,当然是为了使用更简单!为了让我们不用关注那么多的底层细节,把所有精力都放在实际问题上面。Tesorflow与theano是可以使用Nvidia GPU进行加速的,如果你的GPU不支持CUDA,那么也不用担心,那就使用CPU,只是速度慢点(其实是慢很多!(^_^))。如果你的GPU支持CUDA,不用犹豫了,果断使用CUDA进行加速吧,速度快个10~20倍,那是常事。好了说了这么多,下面进入正题。一、文件准备windows 10 64bit旗舰版(版本1607,OS内部版本 )cuda_8.0.44_win10.exe: CUDA安装文件。。CUDA是由显卡厂商NVIDIA推出的通用并行计算架构,该架构使GPU能够解决复杂的计算问题。Visual Studio 2015 Community: 请使用Community版本(社区版),因为它是免费的!免费的!当然,你注册个微软账号使用起来就更好了。Rapid Environment Editor(环境变量编辑器)先把它安装了吧,编辑环境变量方便点。Anaconda3-4.2.0-Windows-x86_64.exeAnaconda是一个Python科学计算环境,提供了很多常用的Python库,例如:numpy,scipy, matplotlib等等。自带的包管理器conda也很强大,可以方便地安装各种Python库。下载地址:DXSDK_Jun10.exe微软的DirectX SDK工具包,不安装它的话,后面编辑CUDA_Samples是没法成功的。下载地址:cudnn-8.0-windows10-x64-v5.1.zipCUDA的神经网络加速库,可以在前面GPU加速基础上大概再提升1.5倍的速度。 下载地址:1. 安装Rapid Environment Editor这个东西是编辑环境变量的,挺好用的,先把它安装了吧。后面给自己省事。安装完成后,默认界面是英文的,到设置里面改为中文吧。启动的时候,设置位管理员启动吧,不然没法更改系统环境变量。2. 安装DXSDK_Jun10.exe直接按照提示下一步就好了。我在windows 10上安装的时候,最后的时候会报错,不过没有关系,关掉那个框。搜索下"d3dx9.h"、"d3dx10.h"、"d3dx11.h"头文件是不是存在,如果路径如下这个样子,就成功了。路径:C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include\d3dx9.hDirectX SDK S1023错误.png 二、安装CUDA深度学习库如果使用CUDA进行GPU加速,可以大大缩短计算时间。如果不需要GPU加速,直接跳到第三部分。2.1 检查GPU是否支持CUDA先确定下自己的显卡型号(不要告诉我你不知道怎么查看自己的显卡型号)。安装CUDA前先检查下,自己的显卡是否支持CUDA,可以从下面的网址查看自己的显卡是否在支持之列。如果你的显卡比较新,到这里检查是否支持CUDA: 如果你的显卡很老,请到如下链接检查是否支持CUDA:注意笔记本和desktop的区别。如果自己电脑显卡不支持的话就跳过第二部分,直接到第三部分。我的显卡是GTX650,是支持CUDA的,所以继续。2.2 安装Visual Studio 2015 communityVisual Studio 2015 community的安装包到哪里找,我就不说了。安装VS2015前,请先断网,不然安装过程会下载一堆东西,过程极慢。安装时只选择Visual C++部分,其他都可以不装,这样安装起来更快。安装要一会儿,请耐心等待。2.3 CUDA安装1. CUDA 8.0下载从CUDA的官网下载安装文件, CUDA 8.0. 注意选择系统是windows 10,选择exe(local)那个Installer Type。如下图:CUDA8.0下载.jpg 如果需要下载CUDA的历史版本,请到这里:2. 测试CUDA安装结果打开命令提示符,输入:nvcc -V可以看到如下信息:nvcc.jpg 但是,这样并不代表安装成功了。等把CUDA_Samples示例编译通过不报错了,才能算是成功。3. 编译CUDA示例程序(1)在 c:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0 目录下,有CUDA的示例程序。由于我安装的是VS2015,所以我打开Samples_vs2015.sln那个解决方案文件,将解决方案配置更改为Release和x64.使用Release模型,由于所有程序安装包用的都是64位版本,所以改为x64比较好。(2)右键单击,编译整个解决方案。如果不出意外,将会编译成功。如果提示是缺少:"d3dx9.h"、"d3dx10.h"、"d3dx11.h"头文件 ,说明前面安装DirectX SDK没有安装好,重新安装下DXSDK_Jun10.exe,再次编译。(3)关闭VS2015,在c:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\bin\win64\Release目录下找到deviceQuery.exe这个文件。打开一个cmd窗口,定位到 c:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\bin\win64\Release目录,输入:deviceQuery.exe ,然后回车。会得到如下结果:检查CUDA是否安装成功.jpg 如果你的结果与上面类似,恭喜你!CUDA 8.0安装成功了!如果报错了,请检查下前面的步骤是否严格执行了。重新再来,直到成功。三、安装Tensorflow与Keras3.1 安装Anaconda1. 下载AnacondaAnaconda包含很多科学计算的包,例如numpy、scipy等等,可以为你省去不少麻烦,它的官网在这里: ,下载最新的Anaconda 4.2版本,Python版本选择3.5 64bit的那个版本。下载Anaconda.jpg 万一你执意使用Python 2.7,我只能告诉你,最新的tensorflow-0.12在windows平台可能对python-2.7支持得不够好,中间会出问题的。2. 安装Anaconda如果你之前有安装Anaconda 2系列的,在环境变量里面把相关的环境变量给删除了。C:\Anaconda2
C:\Anaconda2\Scripts
C:\Anaconda2\Library\bin安装挺简单,我一般安装在C盘根目录下:c:\Anaconda3建议大家也安装到根目录下。安装时,在Install for那个界面,建议选择【All Users(requires admin privileges)】那个选项。在如下那个界面中,把两个选项都勾上(默认是勾上的)安装Anaconda-2个选项.png 3.2 更改pip的默认源Python开发安装包时,使用pip进行包安装非常方便。但pip默认的源服务器在国外,下载非常慢,而且经常出现下载后安装出错问题。因此,有必要更换为国内的pypi源。对于windows来说,直接在当前用户目录下新建一个pip.ini文件,例如:c:\Users\Luoge\pip.inipip.ini的文件内容如下:[global]
index-url = /pypi/simple/
trusted-host=上面是将源更换为了阿里云的源(阿里爸爸牛逼!~),输入完成后,记得保存。3.3 安装Tensorflow下面两种安装方式二选一。在线网络安装方式保持网络连接,从开始菜单中打开Anaconda Prompt,输入:pip install tensorflow-gpu然后就耐心等待吧。如果安装成功了,跳过离线安装方式。在线安装tensorflow.png 如果它提示你更新pip,你就按照提示更新pip好了。如果这种方式安装失败了,请看下面的 离线安装方式 离线安装方式如果在线从pip安装tensorflow总是失败,那就下载python的whl包,本地安装的。下载地址: Ctrl+F搜索Tensorflow,找到: tensorflow_gpu?0.12.0rc1?cp35?cp35m?win_amd64.whl注意下载带gpu字样的版本,它才支持GPU加速。下载也不太快,视你的网速而定。为了方便大家,我在百度云上上传了一份,大家也可以上百度云下载:不客气!从开始菜单中打开Anaconda Prompt,输入:pip install
c:\Users\Luoge\Downloads\tensorflow_gpu-0.12.0rc1-cp35-cp35m-win_amd64.whl然后,等待安装完成就好了。3.4 安装Keras保持网络连接,从开始菜单中打开Anaconda Prompt,输入:pip install keras回车,安装就开始了,它会顺带把Theano也给安装上,但是这里安装的Theano版本比较老,是Theano-0.8.2。我们使用tensorflow作为后端,而不是theano,所以不用理会它,让它装上就好了。四、测试Keras是否安装成功从开始菜单中打开Anaconda Prompt,在命令行中输入:python,再输入:import tensorflow as tf
sess = tf.Session()
a = tf.constant(10)
b = tf.constant(22)
print(sess.run(a + b))如果正确打印出结果32,不报错,说明tensorflow安装成功。再输入:import keras若不报错,说明安装成功。五、让速度更快一点1. cuDNN可以在前面GPU加速基础上大概再提升1.5倍的速度,它由nVIDIA开发。可以到nVIDIA官网上下载。下载之前需要注册,然后问一系列问题,请耐心弄完。然后就可以下载了。不要下载错了,下载windows 10系统下64位的,最新的支持CUDA 8.0的cuDNN-5.1,文件名是:cudnn-8.0-windows10-x64-v5.1.zip下载cudnn.jpg 2. 下载完成后解压缩。里面有bin、include、lib三个目录,将三个文件夹复制到安装CUDA的地方覆盖对应文件夹,默认文件夹在:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.03. 如何验证CuDNN是否配置成功呢?打开Anaconda Prompt,输入python,再输入import tensorflow,显示的如果是下图这样子,不提示没有安装cudnn,就成功了。cudnn安装成功后.jpg
阅读(271)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
在LOFTER的更多文章
loftPermalink:'',
id:'fks_',
blogTitle:'windows 10 64bit下安装Tensorflow+Keras+VS2015+CUDA8.0 GPU加速',
blogAbstract:'来源:windows 10 64bit下安装Tensorflow+Keras+VS2015+CUDA8.0 GPU加速/p/c245d46d43f0写在前面的话',
blogTag:'机器学习,神经网络,cuda,英伟达,gpu编程',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:9,
publishTime:4,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}TensorFlow —— GPU版安装指南_美文阅读,精品文摘网
当前位置: &>&&>& >
TensorFlow —— GPU版安装指南
CPU版的TensorFlow安装还是十分简单的,也就是几条命令的时,但是GPU版的安装起来就会有不少的坑。在这里总结一下整个安装步骤,以及在安装过程中遇到的问题和解决方法。
安装GPU版的TensorFlow和CPU版稍微有一些区别,这里先做一个简单的梳理,后面有详细的安装过程。
NVIDIA Cuda
TensorFlow
0x01 安装Python
这里有两种安装的方法:
安装基本的Python环境,需要什么再继续安装。
安装Anaconda,基本上能用到的包都有包含。
笔者都是直接安装Anaconda了,省事,直接在官网下载安装即可,没什么写的。
下面给出安装基本Python环境的命令。
apt-get install python-pip python-dev python-virtualenv
0x02 安装NVIDIA Cuda
整体参考说明:/cuda/cuda-installation-guide-linux/index.html#runfile
安装Cuda主要有下面几个步骤:
确认电脑的显卡支持cuda
确认Linux版本是否支持cuda
确认gcc是否安装
确认kernel版本
禁用开源驱动
关闭x server
前面几个步骤,主要是做各种前置条件验证的。本文的操作基于Ubuntu16.04,而且电脑本来就是双显卡,基本没什么问题。
主要的坑在安装cuda
1. 验证安装环境
友情提示: 这几步笔者基本上就跳过了,基本上没什么问题,感兴趣或者对自己系统不了解的可以验证一下。
确认电脑的显卡支持cuda
确认Linux版本是否支持cuda
确认gcc是否安装
确认kernel版本
2.1. Verify You Have a CUDA-Capable GPU
To verify that your GPU is CUDA-capable, go to your distribution's equivalent of System Properties, or, from the command line, enter:
$ lspci | grep -i nvidia
If you do not see any settings, update the PCI hardware database that Linux maintains by entering update-pciids (generally found in /sbin) at the command line and rerun the previous lspci command.
If your graphics card is from NVIDIA and it is listed in /cuda-gpus, your GPU is CUDA-capable.
The Release Notes for the CUDA Toolkit also contain a list of supported products.
2.2. Verify You Have a Supported Version of Linux
The CUDA Development Tools are only supported on some specific distributions of Linux. These are listed in the CUDA Toolkit release notes.
To determine which distribution and release number you're running, type the following at the command line:
$ uname -m cat /etc/*release
You should see output similar to the following, modified for your particular system:
Red Hat Enterprise Linux Workstation release 6.0 (Santiago)
The x86_64 line indicates you are running on a 64-bit system. The remainder gives information about your distribution.
2.3. Verify the System Has gcc Installed
The gcc compiler is required for development using the CUDA Toolkit. It is not required for running CUDA applications. It is generally installed as part of the Linux installation, and in most cases the version of gcc installed with a supported version of Linux will work correctly.
To verify the version of gcc installed on your system, type the following on the command line:
$ gcc --version
If an error message displays, you need to install the development tools from your Linux distribution or obtain a version of gcc and its accompanying toolchain from the Web.
2.4. Verify the System has the Correct Kernel Headers and Development Packages Installed
The CUDA Driver requires that the kernel headers and development packages for the running version of the kernel be installed at the time of the driver installation, as well whenever the driver is rebuilt. For example, if your system is running kernel version 3.17.4-301, the 3.17.4-301 kernel headers and development packages must also be installed.
While the Runfile installation performs no package validation, the RPM and Deb installations of the driver will make an attempt to install the kernel header and development packages if no version of these packages is currently installed. However, it will install the latest version of these packages, which may or may not match the version of the kernel your system is using. Therefore, it is best to manually ensure the correct version of the kernel headers and development packages are installed prior to installing the CUDA Drivers, as well as whenever you change the kernel version.
The version of the kernel your system is running can be found by running the following command:
$ uname -r
This is the version of the kernel headers and development packages that must be installed prior to installing the CUDA Drivers. This command will be used multiple times below to specify the version of the packages to install. Note that below are the common-case scenarios for kernel usage. More advanced cases, such as custom kernel branches, should ensure that their kernel headers and sources match the kernel build they are running.
RHEL/CentOS
The kernel headers and development packages for the currently running kernel can be installed with:
$ sudo yum install kernel-devel-$(uname -r) kernel-headers-$(uname -r)
The kernel headers and development packages for the currently running kernel can be installed with:
$ sudo dnf install kernel-devel-$(uname -r) kernel-headers-$(uname -r)
OpenSUSE/SLES
Use the output of the uname command to determine the running kernel's version and variant:
$ uname -r
3.16.6-2-default
In this example, the version is 3.16.6-2 and the variant is default. The kernel headers and development packages can then be installed with the following command, replacing &variant& and &version& with the variant and version discovered from the previous uname command:
$ sudo zypper install kernel-&variant&-devel=&version&
The kernel headers and development packages for the currently running kernel can be installed with:
$ sudo apt-get install linux-headers-$(uname -r)
Read more at: /cuda/cuda-installation-guide-linux/index.html#ixzz4b1TabLmw
Follow us: @GPUComputing on Twitter | NVIDIA on Facebook
2. 禁用开源驱动
注意:有些教程会有更多需要禁用的驱动,这里遵循官网的说明,没有问题。
新建一个文件
vim /etc/modprobe.d/blacklist-nouveau.conf
文件内容为
blacklist nouveau
options nouveau modeset=0
update一下
sudo update-initramfs -u
3. 关闭X server
当我们安装 NVIDIA 的驱动程序时,需要先关闭 X server,关闭的方式有两种:
关闭lightdm
第一种不行时,尝试用第二种。 本文使用的是第二种关闭方式。
sudo /etc/init.d/gdm stop
sudo /etc/init.d/gdm status
sudo /etc/init.d/lightdm stop
sudo /etc/init.d/lightdm status
注意:后面显卡驱动程序安装完毕后,应首先重启 gdm 或者 lightdm。
4. 下载cuda
官网下载即可。 目前这种方式是最靠谱的。/cuda-downloads
注意:这里在选择下载文件时选择的是.run后缀的文件。用别的遇到了一些坑,最后发现这个最稳定。
Paste_Image.png
5. 安装cuda
注意:安装过程中有坑,请重视下面的说明,否则安装后的ubuntu可能会出现无法进入图形界面的情况。因为这个原因,笔者重做了一晚上的操作系统,尝试了3个Ubuntu的版本和两个Centos的版本。
其它的步骤,跟着说明点就行,主要注意图中框的地方。
Paste_Image.png
安装cuda时一定不要安装OpenGL;切记,否则有可能在安装完之后无法启动图形化桌面。
Paste_Image.png
显卡驱动程序安装完毕后,应首先重启 gdm 或者 lightdm。
6. 添加环境变量
在官网里面需要配置环境变量。
在terminal根目录中输入以下命令:
$ sudo vim ~/.bash_profile
在打开的文本末尾加入:
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
export CUDA_HOME=/usr/local/cuda
0x03 安装cuDNN
下面是下载地址,需要提前注册。 注册一下就好。
注意下载的版本。
/rdp/cudnn-download
Paste_Image.png
下载下来的文件就deb包,直接dpkg -i 安装即可。
0x04 安装TensorFlow
Tensorflow官网中有很详细的说明。笔者建议无论是Anaconda还是原生Python环境,都使用pip安装,最为简便,版本也很新。
pip install tensorflow
另外,如果使用Anaconda的conda安装,有一个好处就是可以为Tensorflow单独建一个虚拟环境,但要注意输入正确的Tensorflow包地址(gpu还是cpu版本、操作系统、Python版本等)。在/tensorflow/里有所有Tensorflow包的列表(XML格式)。
建一个虚拟环境
$ conda create -n tensorflow
Activate虚拟环境
$ source activate tensorflow
(tensorflow)$ # Your prompt should change
安装tensorflow
(tensorflow)$ pip install --ignore-installed --upgrade \
/tensorflow/linux/gpu/tensorflow-1.0.1-cp27-cp27m-linux_x86_64.whl
0x05 验证安装
这里跑一个小例子来验证一下。
Then, enter the following short program inside the python interactive shell:
&&& import tensorflow as tf
&&& hello = tf.constant('Hello, TensorFlow!')
&&& sess = tf.Session()
&&& print(sess.run(hello))
If the system outputs the following, then you are ready to begin running TensorFlow programs:
Hello, TensorFlow!
作者:cathyxlyl | she | GITHUB
个人主页:http://cathyxlyl.github.io/文章可以转载, 但必须以超链接形式标明文章原始出处和作者信息
延伸阅读:
(责任编辑:美朵)
每日重点推荐
  ■刘同:青年作家,现任光线影业副总裁,曾出版《谁的青春不迷茫》《你的孤独虽败犹荣》等作品。  大三的时候,我去报社实习,一起进报社的有很多实习生。知道能去报社实习的时候特别开心,觉得这是一个很难得...
05-13 04-15 04-09 04-09 04-09 04-05 12-15 12-15
一周热点文章
在线阅读专题Ubuntu&16.04下安装Tensorflow(GPU)_Cloud_新浪博客
Ubuntu&16.04下安装Tensorflow(GPU)
1.首先安装nvidia显卡驱动:
系统设置-&软件更新-&附加驱动-&选择nvidia最新驱动(361)-&应用更改
​2.下载CUDA8.0
地址/cuda-release-candidate-download(需要登陆)
3.安装cuda&
sudo dpkg -i
cuda-repo-ubuntu-rc_8.0.27-1_amd64​.deb
sudo apt-get
sudo apt-get install
cuda​
4.下载cudnn,最好是v4版本
地址https:/cudnn
5.把cudnn解压复制到cuda下
cudnn-7.0-linux-x64-v4.0-prod.tgz
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.h
/usr/local/cuda/lib64/libcudnn*​​
6.从源码安装tensorflow
/tensorflow/tensorflow​
进入tensorflow根目录(home下)运行./configure配置tensorflow
7.安装Bazel
http://www.bazel.io/docs/install.html​
安装其他依赖
sudo apt-get install python-numpy swig python-dev
python-wheel​​
8.建立GPU支持
bazel build -c opt --config=cuda
//tensorflow/cc:tutorials_example_trainer​
如发生错误可在后面加上--verbose_failures运行如下
bazel build -c opt --config=cuda
//tensorflow/cc:tutorials_example_trainer​
--verbose_failures
完成后运行
​bazel-bin/tensorflow/cc/tutorials_example_trainer
--use_gpu​
此程序会计算一个2*2矩阵的主特征值
创建PIP安装包
bazel build -c opt --config=cuda
//tensorflow/tools/pip_package:build_pip_package​
--config=cuda表示支持gpu
bazel-bin/tensorflow/tools/pip_package/build_pip_package
/tmp/tensorflow_pkg​
sudo pip install
/tmp/tensorflow_pkg/tensorflow-0.9.0-py2-none-any.whl
OK,搞完收工​​
博客等级:
博客积分:0
博客访问:7,851
关注人气:0
荣誉徽章:

我要回帖

更多关于 tensorflow gpu 的文章

 

随机推荐