Ubuntu14.04下安装Tensorflow遇到的问题

安装步骤:

首先说说安装步骤,挺简单的,就是确认pip和Python的版本

pip -V

python

如果不是最新版本就更新一下

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

然后就是安装Tensorflow了

$pip install tensorflow # Python 2.7; CPU support (no GPU support)

$pip3 install tensorflow # Python 3.n; CPU support (no GPU support)

$pip install tensorflow-gpu # Python 2.7; GPU support

$pip3 install tensorflow-gpu # Python 3.n; GPU support 

如果上面的步骤不成功,就使用下面的命令:

$sudo pip install --upgradeTF_PYTHON_URL # Python 2.7

$sudo pip3 install --upgradeTF_PYTHON_URL # Python 3.N

各种版本的下载地址:

Python 2.7

CPU only:

 
 
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.1.0-cp27-none-linux_x86_64.whl

GPU support:

 
 
https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.1.0-cp27-none-linux_x86_64.whl

Python 3.4

CPU only:

 
 
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.1.0-cp34-cp34m-linux_x86_64.whl

GPU support:

 
 
https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.1.0-cp34-cp34m-linux_x86_64.whl

Python 3.5

CPU only:

 
 
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.1.0-cp35-cp35m-linux_x86_64.whl

GPU support:

 
 
https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.1.0-cp35-cp35m-linux_x86_64.whl

Python 3.6

CPU only:

 
 
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.1.0-cp36-cp36m-linux_x86_64.whl

GPU support:

 
 
https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.1.0-cp36-cp36m-linux_x86_64.whl

验证tensorflow是否安装成功

  1. 启动终端,输入python
  2. 输入以下代码:
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
  
  
  • 1
  • 2
  • 3
  • 4
  • 1
  • 2
  • 3
  • 4

如果输出Hello, TensorFlow!则代表安装成功。


查看Tensorflow版本:


$ pip show tensorflow


问题:

安装之后测试发现以下问题,搜了很多安装经验,我感觉应该是我之前安装的Tensorflow有冲突,虽然显示安装成功了,运行却出错。试了好多办法都不可行,无奈我把Ubuntu重新装了一下,一切就正常了。

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 104, in <module>
    from tensorflow.python.platform import test
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/test.py", line 53, in <module>
    import mock                # pylint: disable=g-import-not-at-top,unused-import
  File "/usr/local/lib/python2.7/dist-packages/mock/__init__.py", line 2, in <module>
    import mock.mock as _mock
  File "/usr/local/lib/python2.7/dist-packages/mock/mock.py", line 69, in <module>
    from pbr.version import VersionInfo
ImportError: No module named pbr.version


Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 51, in <module>
    from tensorflow.python import pywrap_tensorflow
ImportError: cannot import name pywrap_tensorflow










评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值