TensorFlow的安装要求操作系统时64位,如果不是64位,只好装个64位系统啦。windows使用Docker安装,Mac和Linux安装相似:
先下载好tensorflow-0.5.0-cp27-none-linux_x86_64(https://github.com/tensorflow/tensorflow)
这是我成功安装的方法:
$ sudo apt-get install python-pip python-dev python-virtualenv
$ virtualenv --system-site-packages ~/tensorflow
$ cd ~/tensorflow #创建一个工作空间
$ source bin/activate #启用工作空间
(tensorflow)$ pip install --upgrade tensorflow-0.5.0-cp27-none-linux_x86_64.whl #安装tensorflow
测试一下:
yanglei@yanglei-Lenovo-G405s:~$ cd ~/tensorflow
yanglei@yanglei-Lenovo-G405s:~/tensorflow$ source bin/activate
(tensorflow) yanglei@yanglei-Lenovo-G405s:~/tensorflow$ python2
Python 2.7.11+ (default, Apr 17 2016, 14:00:29)
[GCC 5.3.1 20160413] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> a = tf.placeholder("float")
>>> b = tf.placeholder("float")
>>> y = tf.mul(a, b)
>>> sess = tf.Session()
I tensorflow/core/common_runtime/local_device.cc:25] Local device intra op parallelism threads: 4
I tensorflow/core/common_runtime/local_session.cc:45] Local session inter op parallelism threads: 4
>>> print "%f should equal 2.0" % sess.run(y, feed_dict={a: 1, b: 2})
2.000000 should equal 2.0
>>> print "%f should equal 9.0" % sess.run(y, feed_dict={a: 3, b: 3})
9.000000 should equal 9.0