TensorFlow learning one (1) installation

I am using a mac, go directly to the theme, install

1. Install python before installing TensorFlow. I use brew to install it. For more information on brew, see https://brew.sh/

 

beew install python

 2. After the python installation is complete, you can follow pip, which is a Python package management tool. Next follow tensorflow with pip

pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl

 If you see the following information, the installation is successful, congratulations.

$ pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl
Collecting tensorflow==0.5.0 from https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl
  Downloading https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl (9.8MB)
    100% |████████████████████████████████| 9.8MB 113kB/s
Collecting numpy>=1.9.2 (from tensorflow==0.5.0)
  Downloading numpy-1.13.3-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (4.6MB)
    100% |████████████████████████████████| 4.6MB 12kB/s
Collecting six>=1.10.0 (from tensorflow==0.5.0)
  Downloading six-1.11.0-py2.py3-none-any.whl
Installing collected packages: numpy, six, tensorflow
Successfully installed numpy-1.13.3 six-1.11.0 tensorflow-0.5.0

 3. I want to try the official example. Try my first TensorFlow program

console input python

$ python
Python 2.7.14 (default, Sep 25 2017, 09:53:22)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
can't determine number of CPU cores: assuming 4
I tensorflow/core/common_runtime/local_device.cc:25] Local device intra op parallelism threads: 4
can't determine number of CPU cores: assuming 4
I tensorflow/core/common_runtime/local_session.cc:45] Local session inter op parallelism threads: 4
>>> print sess.run(hello)
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print sess.run(a+b)
42

 There is an error in the middle, but it does not affect the program execution. It was found that the version of tensorflow we downloaded was too low, and the official version 1.4 has been released, so update tensorflow

Execute the console again

$ pip install -U tensorflow
Collecting tensorflow
  Downloading tensorflow-1.4.0-cp27-cp27m-macosx_10_11_x86_64.whl (38.8MB)
    11% |███▌ | 4.3MB 20kB/s eta 0:28:18

 

This time I downloaded 1.4. Long wait, only 4.3 after half a day, students who can't wait can modify the source of pip

If there is no .pip folder, then create a new folder, mkdir .pip
Then create a new file touch pip.conf in the .pip folder,

Edit the pip.conf file and write to Alibaba Cloud

[global]

index-url = http://mirrors.aliyun.com/pypi/simple/

[install]

trusted-host=mirrors.aliyun.com

 The back is fast.

$ pip install -U tensorflow
Collecting tensorflow
  Downloading http://mirrors.aliyun.com/pypi/packages/d6/1b/c0cabf27871cd71c3b02c8e94ee74703f6a240eaf7a139b0f0fcef85aa1c/tensorflow-1.4.0-cp27-cp27m-macosx_10_11_x86_64.whl (38.8MB)
    100% |████████████████████████████████| 38.9MB 8.1MB/s
Requirement already up-to-date: six>=1.10.0 in /usr/local/lib/python2.7/site-packages (from tensorflow)
Collecting protobuf>=3.3.0 (from tensorflow)
  Downloading http://mirrors.aliyun.com/pypi/packages/74/34/52e4fcc023f36ba8c408765032e6b9052eff115b01a17e3d2af48fac3a97/protobuf-3.5.0.post1-py2.py3-none-any.whl (389kB)
    100% |████████████████████████████████| 389kB 6.9MB/s
Collecting enum34>=1.1.6 (from tensorflow)
  Downloading http://mirrors.aliyun.com/pypi/packages/c5/db/e56e6b4bbac7c4a06de1c50de6fe1ef3810018ae11732a50f15f62c7d050/enum34-1.1.6-py2-none-any.whl
Collecting tensorflow-tensorboard<0.5.0,>=0.4.0rc1 (from tensorflow)
  Downloading http://mirrors.aliyun.com/pypi/packages/d5/fb/80df4eb3234c41beeeb3122b1966effbf08608fb80d2fa74bb72f8da9cb3/tensorflow_tensorboard-0.4.0rc3-py2-none-any.whl (1.7MB)
    100% |████████████████████████████████| 1.7MB 4.5MB/s
Collecting mock>=2.0.0 (from tensorflow)
  Downloading http://mirrors.aliyun.com/pypi/packages/e6/35/f187bdf23be87092bd0f1200d43d23076cee4d0dec109f195173fd3ebc79/mock-2.0.0-py2.py3-none-any.whl (56kB)
    100% |████████████████████████████████| 61kB 17.6MB/s
Requirement already up-to-date: numpy>=1.12.1 in /usr/local/lib/python2.7/site-packages (from tensorflow)
Requirement already up-to-date: wheel in /usr/local/lib/python2.7/site-packages (from tensorflow)
Collecting backports.weakref>=1.0rc1 (from tensorflow)
  Downloading http://mirrors.aliyun.com/pypi/packages/88/ec/f598b633c3d5ffe267aaada57d961c94fdfa183c5c3ebda2b6d151943db6/backports.weakref-1.0.post1-py2.py3-none-any.whl
Collecting setuptools (from protobuf>=3.3.0->tensorflow)
  Downloading http://mirrors.aliyun.com/pypi/packages/0f/40/b3c98aa32bc91d3d8c573443a29aa482d77268d77132b63f09d8385b21ff/setuptools-37.0.0-py2.py3-none-any.whl (481kB)
    100% |████████████████████████████████| 491kB 10.3MB/s
Collecting werkzeug>=0.11.10 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow)
  Downloading http://mirrors.aliyun.com/pypi/packages/97/02/306e0d57fdbf467ec1c763bc1757ec6ba20b1332e0ea7e49111533d71d1c/Werkzeug-0.12.2-py2.py3-none-any.whl (312kB)
    100% |████████████████████████████████| 317kB 32.0MB/s
Collecting markdown>=2.6.8 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow)
  Downloading http://mirrors.aliyun.com/pypi/packages/29/82/dfe242bcfd9eec0e7bf93a80a8f8d8515a95b980c44f5c0b45606397a423/Markdown-2.6.9.tar.gz (271kB)
    100% |████████████████████████████████| 276kB 811kB/s
Collecting futures>=3.1.1; python_version < "3.2" (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow)
  Downloading http://mirrors.aliyun.com/pypi/packages/a6/1c/72a18c8c7502ee1b38a604a5c5243aa8c2a64f4bba4e6631b1b8972235dd/futures-3.1.1-py2-none-any.whl
Collecting bleach==1.5.0 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow)
  Downloading http://mirrors.aliyun.com/pypi/packages/33/70/86c5fec937ea4964184d4d6c4f0b9551564f821e1c3575907639036d9b90/bleach-1.5.0-py2.py3-none-any.whl
Collecting html5lib==0.9999999 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow)
  Downloading http://mirrors.aliyun.com/pypi/packages/ae/ae/bcb60402c60932b32dfaf19bb53870b29eda2cd17551ba5639219fb5ebf9/html5lib-0.9999999.tar.gz (889kB)
    100% |████████████████████████████████| 890kB 4.2MB/s
Collecting funcsigs>=1; python_version < "3.3" (from mock>=2.0.0->tensorflow)
  Downloading http://mirrors.aliyun.com/pypi/packages/69/cb/f5be453359271714c01b9bd06126eaf2e368f1fddfff30818754b5ac2328/funcsigs-1.0.2-py2.py3-none-any.whl
Collecting pbr>=0.11 (from mock>=2.0.0->tensorflow)
  Downloading http://mirrors.aliyun.com/pypi/packages/0c/5d/b077dbf309993d52c1d71e6bf6fe443a8029ea215135ebbe0b1b10e7aefc/pbr-3.1.1-py2.py3-none-any.whl (99kB)
    100% |████████████████████████████████| 102kB 8.7MB/s
Building wheels for collected packages: markdown, html5lib
  Running setup.py bdist_wheel for markdown ... done
  Stored in directory: /Users/da_peng/Library/Caches/pip/wheels/73/ad/47/9f37537924b4a61feef8150486069191bc0994416a677b7408
  Running setup.py bdist_wheel for html5lib ... done
  Stored in directory: /Users/da_peng/Library/Caches/pip/wheels/e4/68/0c/85c19b1fbe67607477168d154bd1c20ba586fc23988e03818a
Successfully built markdown html5lib
Installing collected packages: setuptools, protobuf, enum34, werkzeug, markdown, futures, html5lib, bleach, tensorflow-tensorboard, funcsigs, pbr, mock, backports.weakref, tensorflow
  Found existing installation: setuptools 36.5.0
    Uninstalling setuptools-36.5.0:
      Successfully uninstalled setuptools-36.5.0
  Found existing installation: tensorflow 0.5.0
    Uninstalling tensorflow-0.5.0:
      Successfully uninstalled tensorflow-0.5.0
Successfully installed backports.weakref-1.0.post1 bleach-1.5.0 enum34-1.1.6 funcsigs-1.0.2 futures-3.1.1 html5lib-0.9999999 markdown-2.6.9 mock-2.0.0 pbr-3.1.1 protobuf-3.5.0.post1 setuptools-37.0.0 tensorflow-1.4.0 tensorflow-tensorboard-0.4.0rc3 werkzeug-0.12.2

 The installation is complete, then start the tensorflow journey

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326282967&siteId=291194637