ubuntu14.04安装tensorflow遇到的坑

此处参考http://blog.csdn.net/langb2014/article/details/51579491

Tensorflow

1、先下载v0.8版的GPU支持

  1. sudo apt-get install python-pip python-dev   

2、如果中途安装不了可以先下载那个网址东西,下载好了,然后安装,中途会有几个包的numpy、six、protobuf、wheel下载安装比较慢或者下载不了,可以单独安装。

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

3、测试Tensorflow

  1. python  
  2. >>> import tensorflow as tf  
  3. >>> exit() 
运气好的到此结束,但是基本都会遇到问题,一下内容只适用于我,读完再操作,我遇到问题有

SSLError: The read operation timed out

Storing debug log for failure in /home/hjxu/.pip/pip.log

这是什么情况,我的机器本来没有安装tensoeflow,所以我安装tensorflow没有--upgrate这句

  1. sudo pip install https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl 
然后又遇到

wnloading/unpacking numpy>=1.8.2 (from tensorflow==0.8.0)
  Cannot fetch index base URL https://pypi.python.org/simple/
  Could not find any downloads that satisfy the requirement numpy>=1.8.2 (from tensorflow==0.8.0)

what fuck?查资料后参考http://www.th7.cn/Program/delphi/201509/553938.shtml

这是源的问题,正常安装你的根目录下会有这个.pip这个文件夹,ctrl+h可见,在这个文件夹下建立pip.conf文件。代码如下

cd .pip
sudo touch pip.conf   #建立pip.conf文件
sudo gedit pip.conf   #编辑pip.conf文件

然后输入[global]index-url=http://pypi.douban.com/simplev2ex:http://pypi.v2ex.com/simple      保存退出

然后再重新安装

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

又遇到SSLError: The read operation timed out

总是这么命运多舛

后来发现可能是pip版本问题,执行下面代码

sudo pip install --upgrade pip
然后再安装

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

然后出现

InsecurePlatformWarning
  Downloading https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl (22.2MB)
    100% |████████████████████████████████| 22.2MB 88kB/s
Collecting numpy>=1.8.2 (from tensorflow==0.8.0)
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading numpy-1.12.1-cp27-cp27mu-manylinux1_x86_64.whl (16.5MB)
    100% |████████████████████████████████| 16.5MB 115kB/s
Collecting six>=1.10.0 (from tensorflow==0.8.0)
  Downloading six-1.10.0-py2.py3-none-any.whl
Collecting protobuf==3.0.0b2 (from tensorflow==0.8.0)
  Downloading protobuf-3.0.0b2-py2.py3-none-any.whl (326kB)
    100% |████████████████████████████████| 327kB 1.4MB/s
Collecting wheel (from tensorflow==0.8.0)
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
    100% |████████████████████████████████| 71kB 1.5MB/s
Collecting setuptools (from protobuf==3.0.0b2->tensorflow==0.8.0)
  Downloading setuptools-35.0.1-py2.py3-none-any.whl (390kB)
    100% |████████████████████████████████| 399kB 1.0MB/s
Collecting appdirs>=1.4.0 (from setuptools->protobuf==3.0.0b2->tensorflow==0.8.0)
  Downloading appdirs-1.4.3-py2.py3-none-any.whl
Collecting packaging>=16.8 (from setuptools->protobuf==3.0.0b2->tensorflow==0.8.0)
  Downloading packaging-16.8-py2.py3-none-any.whl
Collecting pyparsing (from packaging>=16.8->setuptools->protobuf==3.0.0b2->tensorflow==0.8.0)
  Downloading pyparsing-2.2.0-py2.py3-none-any.whl (56kB)
    100% |████████████████████████████████| 61kB 1.6MB/s
Installing collected packages: numpy, six, appdirs, pyparsing, packaging, setuptools, protobuf, wheel, tensorflow
  Found existing installation: six 1.5.2
    DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling six-1.5.2:
      Successfully uninstalled six-1.5.2
  Found existing installation: setuptools 3.3
    Uninstalling setuptools-3.3:
      Successfully uninstalled setuptools-3.3
  Found existing installation: wheel 0.24.0
    Uninstalling wheel-0.24.0:
      Successfully uninstalled wheel-0.24.0
Successfully installed appdirs-1.4.3 numpy-1.12.1 packaging-16.8 protobuf-3.0.0b2 pyparsing-2.2.0 setuptools-35.0.1 six-1.10.0 tensorflow-0.8.0 wheel-0.29.0
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning

在终端 测试了一下

python
import tensorflow

没有报错,OK,解决了,之前还有一次遇坑

AttributeError: NewBase is_abstract, ImportError: libcudart.so.7.5

解决:是因为six版本问题

  1. $sudo pip install six --upgrade --target="/usr/lib/python2.7/dist-packages" 
祝好运
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值