tensorflow 运行成功!

折腾了一天安装tensorflow环境,终于可以运行,也记录一下安装中容易犯的错误总结(写给python小白们)

一、win7 双系统 安装ubuntu 16.04 ,参考 http://jingyan.baidu.com/article/60ccbceb18624464cab197ea.html

以下是容易遇到的问题:

1、iso要用64位系统

2、安装过程中,联想Thinkpad 按F1 进入Bois 可能需要修改 “F12 选择启动方式”的选项,确保该项为Enable

3、重启 , F12 , 选择USB HDD 启动,进行ubuntu 的安装

4、分区过程中, 如果window系统已经用了很多个主分区, ubuntu添加分区的时候 ,都选逻辑分区, 否则会遇到磁盘不可用的问题, 因为最多只能有4个主分区

二、ubuntu中安装环境

1、更新源, 16.04的选用了aliyun的比较快

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

2、ubuntu su root
使用当前登录账号, sudo passwd root
设置密码, 然后就可以 su root 了

3、安装python pip

ubuntu16.04自带python2.7.11+ 和 python 3.5.5, 不用自己编译安装, 默认 python是python2.7.11, python3是python3.5.5

直接apt-get install 无法安装pip 提示缺少很多依赖包, 网上介绍了各种安装pip方法, 使用 get-pip.py 安装最方便, 参考 https://pip.pypa.io/en/stable/installing/

get-pip.py 官网下载地址: https://bootstrap.pypa.io/get-pip.py

执行 python get-pip.py 安装pip (此时安装的是python2.7的pip)

如果再使用 python3 get-pip.py 顺手把pip3 也装上的话 ,就会发现 pip 变成了 pip3 (可以用 pip -V 查看)

这时需要到 which pip , 到对应目录/usr/local/bin/删掉pip, ln -s pip2 pip , 将pip改回pip2的引用

4、安装tensorflow

安装github上的说明装就可以(其他是前面几部都做对了,尤其是pip)

安装0.8 https://github.com/tensorflow/tensorflow/blob/r0.8/tensorflow/g3doc/get_started/os_setup.md

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

以前一直提示 “xx whl is not a supported wheel on this platform.” 错误, 主要是pip混乱导致的

至此大功告成~

$ 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

posted on 2016-09-01 00:09  eoiioe  阅读(1768)  评论(2编辑  收藏  举报

导航