ubuntu14.04 安装 tensorflow9.0

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Agly_Clarlie/article/details/79463281

ubuntu14.04 安装 tensorflow9.0


ubuntu 14.04 + python27 环境下安装tensorflow-0.9.0
官网网址:http://www.tensorfly.cn/tfdoc/get_started/introduction.html

安装pip(笔者的版本为9.0)

$ sudo apt-get install python-pip python-dev

仅使用 CPU 的版本的tensorflow

$ pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl

测试

正常情况下是没有问题的啦,直接进入python 环境测试:

$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> exit()

不正常的存在
没有报错就是没有安装成功了,但是…

异常情况

1安装tensorflow问题 owned by OS错误

但是笔者安装过程并没有很顺利,执行安装cpu版本的时候就出现问题咯:

   changing mode of /usr/local/bin/f2py to 755
  Found existing installation: wheel 0.24.0
    Not uninstalling wheel at /usr/lib/python2.7/dist-packages, owned by OS
  Found existing installation: six 1.5.2
    Not uninstalling six at /usr/lib/python2.7/dist-packages, owned by OS
Successfully installed tensorflow numpy wheel six
Cleaning up...

2此时进行测试会出现 AttributeError: type object ‘NewBase’ has no attribute ‘is_abstract’

>>> import tensorflow as tf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 23, in <module>
    from tensorflow.python import *
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 97, in <module>
    from tensorflow.python.platform import test
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/test.py", line 62, in <module>
    from tensorflow.python.framework import test_util
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/test_util.py", line 41, in <module>
    from tensorflow.python.platform import googletest
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/googletest.py", line 32, in <module>
    from tensorflow.python.platform import benchmark  # pylint: disable=unused-import
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/benchmark.py", line 112, in <module>
    class Benchmark(six.with_metaclass(_BenchmarkRegistrar, object)):
  File "/usr/lib/python2.7/dist-packages/six.py", line 617, in with_metaclass
    return meta("NewBase", bases, {})
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/benchmark.py", line 107, in __new__
    if not newclass.is_abstract():
AttributeError: type object 'NewBase' has no attribute 'is_abstract'
>>> 

这个问题我是这样排查的:

3第一个是pip的版本太低,需要升级pip:

gu@Ugly:~$ sudo pip install --upgrade pip

Downloading/unpacking pip from https://pypi.python.org/packages/b6/ac/7015eb97dc749283ffdec1c3a88ddb8ae03b8fad0f0e611408f196358da3/pip-9.0.1-py2.py3-none-any.whl#md5=297dbd16ef53bcef0447d245815f5144
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB): 1.3MB downloaded
Installing collected packages: pip
  Found existing installation: pip 1.5.4
    Not uninstalling pip at /usr/lib/python2.7/dist-packages, owned by OS
Successfully installed pip
Cleaning up...

这里又出现问题了,owned by OS错误:

4对于owned by OS错误:

参考 http://blog.csdn.net/xuezhisdc/article/details/49588517
解决问题(参考上面的博客内容)

在/usr/local/lib/python2.7/dist-packages/下,新建mypack.pth文件,输入以下内容
新建这个文件的作用是,Python的搜索路径先搜搜/usr/local/lib/,后搜搜/usr/lib。

   # 文件内容
    /usr/local/lib/python2.7/dist-packages/

更新six

gu@Ugly:~$ sudo pip install six --upgrade

查看pip list

~$: pip list

发现pip 和 six 都升级成功

再次安装tensorflow

gu@Ugly:~$ pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl
展开阅读全文

没有更多推荐了,返回首页