最近安装TensorFlow,发现用的资源链接不同,下载速度及安装过程都不一样,在这个做一个总结:
首先此处我安装的TensorFlow是基于cpu的,采用pip安装,Ubuntu为14.04
TensorFlow过程如下:
下载pip:
$>wget https://bootstrap.pypa.io/get-pip.py
安装pip :
$>sudo python get-pip.py
查看python 与pip版本(Python 2.7.6,pip 18.0):
$>python
$>pip -V
安装TensorFlow:
$>sudo pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/cpu/tensorflow-1.3.0-cp27-none-linux_x86_64.whl
如果TensorFlow在下载package时s在six包处出现问题,则更新six:
$> sudo easy_install --upgrade six
six 更新完成后,再重新安装TensorFlow:
$>sudo pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/cpu/tensorflow-1.3.0-cp27-none-linux_x86_64.whl
python 中尝试导入TensorFlow:
$>python
>>> import tensorflow as tf
如果上步骤提示找不到protobuf模块,则安装protobuf:
$>wget https://pypi.python.org/packages/0f/53/e43b226f83a5a542c16695e9624b7bd2bde4ad016776c7c3233901bcf5b4/protobuf-3.2.0-cp27-cp27mu-manylinux1_x86_64.whl#md5=a1a807fee3a7df784e171837853cc29d #下载指令cp27指Python为2.7
$>pip install protobuf-3.2.0-cp27-cp27mu-manylinux1_x86_64.whl #安装下载的protobuf包
完成protocolbuf的安装之后,再次尝试在Python中导入TensorFlow:
$>python
>>> import tensorflow as tf
>>>
如上,导入过程没有提示任何问题,并且出现‘>>>’,则TensorFlow安装完成,尝试用TensorFlow执行简单功能:
>>> hello = tf.constant('Hello, tensorflow!') >>> sess = tf.Session() W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. >>> print sess.run(hello) Hello, tensorflow! >>> a = tf.constant(10) >>> b = tf.constant(32) >>> print sess.run(a+b) 42 >>>
测试结束!
由于每个人遇到的问题各不相同,想要安装的TensorFlow也不一定是基于CPU的,以下是一个安装TensorFlow遇到问题的帖子,其中最重要的是,提供的有效的资源链接!请参考:
http://www.cnblogs.com/shihuc/p/6593041.html