采用ubuntu系统来安装tensorflow

      最近在学习google新开源的深度学习框架tensorflow。发现安装它的时候,须要依赖python2.7.X;我以前一直使用的linux是centos。而centos不更新了,里面的自带的python通常都是python2.6如下的。不只如此,系统里面不少组件又依赖python2.6,因此致使你都不能替换掉它。无奈之下,选择ubuntu了。下面介绍一下使用ubuntu安装tensorflow遇到的一些问题。python

一、ubuntu没法用Winscp链接linux

解决办法:ubuntu

(1)、采用桥接的方式进行上网(因为是用虚拟机安装的操做系统)centos

(2)、利用ps -e  |grep ssh  查看是否有sshd进程开启。若是没有则须要安装openssh-serverapi

    安装的方式:sudo apt-get install openssh-serverbash

    启动相应的进程:/etc/init.d/ssh start框架

(3)、此时须要reboot系统python2.7

(4)、因为ubuntu最初root的用户是没有被激活的,因此须要经过修改root用户密码来激活root用户。ssh

完成便可链接了。学习

二、安装tensorflow。

因为个人ubuntu是最新版的(ubuntu-16.04-desktop-amd64),里面自带的python是2.7.11。所以知足要求。因为tensorflow有三种安装方式,这里采用的是pip安装方式。下面开始安装tensorflow:

(1)首先安装pip

 sudo apt-get install python-pip python-dev

(2)利用pip安装tensorflow

sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl

安装好了后,以下图所示:

根据上面黄色的提示,叫我升级pip:因而我就按照他的要求升级了,执行:pip install --upgrade pip

 三、检验tensorflow是否安装成功

经过下面一段代码来测试tensorflow是否安装成功:

$ python
...
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print(sess.run(a + b))
42
>>>
下面是我执行的结果以下图所示:

四、安装python-numpy ,python-scipy,python-matplotlib

sudo apt-get install python-numpy

sudo apt-get install python-scipy

sudo apt-get install python-matplotlib

验证是否安装成功:(以下图所示)

 

相关文章
相关标签/搜索