TensorFlow安装

TensorFlow安装

选择对应的whl文件,使用pip安装:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$ sudo pip install tf_nightly-1.head-py3-none-any.whl
Password:
The directory '/Users/LeslieZhu/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/LeslieZhu/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Processing ./tf_nightly-1.head-py3-none-any.whl
Requirement already satisfied: protobuf>=3.4.0 in /usr/local/lib/python3.5/site-packages (from tf-nightly==1.head)
Requirement already satisfied: wheel>=0.26 in /usr/local/lib/python3.5/site-packages (from tf-nightly==1.head)
Collecting numpy>=1.12.1 (from tf-nightly==1.head)
Downloading numpy-1.13.3-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (4.5MB)
100% |████████████████████████████████| 4.5MB 15kB/s
Collecting enum34>=1.1.6 (from tf-nightly==1.head)
Downloading enum34-1.1.6-py3-none-any.whl
Requirement already satisfied: six>=1.10.0 in /usr/local/lib/python3.5/site-packages (from tf-nightly==1.head)
Requirement already satisfied: setuptools in /usr/local/lib/python3.5/site-packages (from protobuf>=3.4.0->tf-nightly==1.head)
Requirement already satisfied: packaging>=16.8 in /usr/local/lib/python3.5/site-packages (from setuptools->protobuf>=3.4.0->tf-nightly==1.head)
Requirement already satisfied: appdirs>=1.4.0 in /usr/local/lib/python3.5/site-packages (from setuptools->protobuf>=3.4.0->tf-nightly==1.head)
Requirement already satisfied: pyparsing in /usr/local/lib/python3.5/site-packages (from packaging>=16.8->setuptools->protobuf>=3.4.0->tf-nightly==1.head)
Installing collected packages: numpy, enum34, tf-nightly
Found existing installation: numpy 1.12.0
Uninstalling numpy-1.12.0:
Successfully uninstalled numpy-1.12.0
Successfully installed enum34-1.1.6 numpy-1.13.3 tf-nightly-1.5.0.dev20171107

测试:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$ ipython
In [1]: import tensorflow as tf
In [2]: hello = tf.constant('Hello, TensorFlow!')
In [3]: sess = tf.Session()
2017-11-08 20:05:39.504360: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
In [4]: sess.run(hello)
Out[4]: b'Hello, TensorFlow!'
In [5]: a = tf.constant(10)
In [6]: b = tf.constant(32)
In [7]: a
Out[7]: <tf.Tensor 'Const_1:0' shape=() dtype=int32>
In [8]: b
Out[8]: <tf.Tensor 'Const_2:0' shape=() dtype=int32>
In [9]: sess.run(a + b)
Out[9]: 42
In [10]: sess.close()
In [11]: quit()

资料

吴羽舒 wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!