[PYTHON] Installing TensorFlow 0.11.0rc2 on OS X El Capitan (10.11.6)

Start studying TensorFlow.

First, prepare the environment. The platform is OS X El Capitan (10.11.6).

I refer to the official documentation Download and Setup.

Install Python 3.5.2 using pyenv

Prepare the Python in the Requirements of Download and Setup (https://www.tensorflow.org/versions/r0.11/get_started/os_setup.html#install-ipython). Python is originally installed on OS X (macOS), but I will install it separately to use the 3rd system. I decided to use pyenv to install Python. I originally used anyenv, so I used ʻanyenv to install pyenvand thenpyenv` to install python 3.5.2. ..

% anyenv install pyenv
Cloning https://github.com/yyuu/pyenv.git...
Cloning into 'pyenv'...
remote: Counting objects: 14083, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 14083 (delta 0), reused 0 (delta 0), pack-reused 14075
Receiving objects: 100% (14083/14083), 2.48 MiB | 1.13 MiB/s, done.
Resolving deltas: 100% (9738/9738), done.
Checking connectivity... done.

Install pyenv succeeded!
Please reload your profile (exec $SHELL -l) or open a new session.

% exec $SHELL -l
% pyenv install 3.5.2
Downloading Python-3.5.2.tar.xz...
-> https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz
Installing Python-3.5.2...
patching file Lib/venv/scripts/posix/activate.fish

You can always use Python 3.5.2 in this environment, so specify the version of Python to use with pyenv global.

% pyenv global 3.5.2
% exec $SHELL -l
% python -V
Python 3.5.2

Requirements describes the dependency when using the GPU version, but I will not use it for the time being.

Install TensorFlow with Pip install

In Overview, consider the range of impact on existing Python-based applications when installing TensorFlow. And some options are shown. This time, I have already installed a dedicated Python environment using pyenv, so I don't have to worry about the impact on the existing environment, so it's easy Pip Installation Select .11 / get_started / os_setup.html # pip-installation).

pip is already installed, but for the time being, use ʻeasy_install` according to the procedure in the official documentation.

% easy_install pip
% easy_install --upgrade six

Next, set the appropriate URL for each environment in the environment variable TF_BINARY_URL. This time, I chose "Mac OS X, CPU only, Python 3.4 or 3.5".

% export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.11.0rc2-py3-none-any.whl
% pip3 install --upgrade $TF_BINARY_URL
Collecting tensorflow==0.11.0rc2 from https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.11.0rc2-py3-none-any.whl
  Downloading https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.11.0rc2-py3-none-any.whl (35.5MB)
    100% |████████████████████████████████| 35.5MB 43kB/s 
Collecting numpy>=1.11.0 (from tensorflow==0.11.0rc2)
  Downloading numpy-1.11.2-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 (3.9MB)
    100% |████████████████████████████████| 3.9MB 391kB/s 
Collecting protobuf==3.0.0 (from tensorflow==0.11.0rc2)
  Downloading protobuf-3.0.0-py2.py3-none-any.whl (342kB)
    100% |████████████████████████████████| 348kB 3.3MB/s 
Requirement already up-to-date: six>=1.10.0 in /Users/xxxxxx/.anyenv/envs/pyenv/versions/3.5.2/lib/python3.5/site-packages/six-1.10.0-py3.5.egg (from tensorflow==0.11.0rc2)
Collecting wheel>=0.26 (from tensorflow==0.11.0rc2)
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
    100% |████████████████████████████████| 71kB 5.8MB/s 
Collecting setuptools (from protobuf==3.0.0->tensorflow==0.11.0rc2)
  Downloading setuptools-28.7.1-py2.py3-none-any.whl (472kB)
    100% |████████████████████████████████| 481kB 2.3MB/s 
Installing collected packages: numpy, setuptools, protobuf, wheel, tensorflow
  Found existing installation: setuptools 20.10.1
    Uninstalling setuptools-20.10.1:
      Successfully uninstalled setuptools-20.10.1
Successfully installed numpy-1.11.2 protobuf-3.0.0 setuptools-28.7.1 tensorflow-0.11.0rc2 wheel-0.29.0
You are using pip version 8.1.1, however version 9.0.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Looking at this, six is also included in the dependency, so it may not have been necessary to upgrade in advance.

And finally, there was a message prompting me to update the version of pip, so I updated it.

% pip install --upgrade pip
Collecting pip
  Downloading pip-9.0.0-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 1.0MB/s 
Installing collected packages: pip
  Found existing installation: pip 8.1.1
    Uninstalling pip-8.1.1:
      Successfully uninstalled pip-8.1.1
Successfully installed pip-9.0.0

Operation check

Check the operation by the method of Run a TensorFlow demo model.

% python
Python 3.5.2 (default, Nov  3 2016, 18:42:02) 
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
b'Hello, TensorFlow!'
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print(sess.run(a + b))
42

The display of'Hello, TensorFlow!'Is a little different from the documentation, but I think this is because the display of b'string' has changed between Python 2.7 and 3.x.

Now you're ready to go.

Recommended Posts

Installing TensorFlow 0.11.0rc2 on OS X El Capitan (10.11.6)
Install matplotlib on OS X El Capitan
Build an environment with pyenv, pyenv-virtualenv, jupyter on OS X El Capitan
R environment construction with Jupyter (formerly IPython notebook) (on OS X El Capitan 10.11.3)
Instructions for installing CUDA 7.5 on Mac (El Capitan) + Homebrew
Run Tensorflow 2.x on Python 3.7
Memo on Mac OS X
When import tkinter is not possible on Mac OS X 10.11.3 (El Capitan) + pyenv + Python 3.5.1.
Build a python environment with pyenv (OS X El Capitan 10.11.3)
Steps to install the latest version of OpenCV on OS X El Capitan without Homebrew
I installed Caffe so that I can do deep learning on MAC OS X El Capitan
Install Sphinx on Mac OS X
Install python3 on Mac (El Capitan)
Install mitmproxy on Mac OS X
Install pgmagick on Mac OS X 10.9
Installed aws-cli On Mac OS X Lion
Use without installing python 2.x on Windows
[Just a note] Until Keras + TensorFlow works on Mac OS X Sierra
Installing PIL with Python 3.x on macOS
Run NASA CEA on Mac OS X
Run Qiita API v2 Python wrapper in Python3 environment (Mac OS X 10.11 (El Capitan))
OS X GPU is now supported in Tensorflow
Run Zookeeper x python (kazoo) on Mac OS X
Installing TensorFlow on Windows Easy for Python beginners
Shpinx (Python documentation builder) on Mac OS X
[Is it explosive !?] Setup for using the GPU version of Tensorflow on OS X
Preparing to use aws cli on Mac OS X
Building an environment for "Tello_Video" on Mac OS X
Very easy to install SciPy on Mac OS X
How to install caffe on OS X with macports
Try using E-Cell 4 on Windows 7 or Mac OS X
Build a Python development environment on Mac OS X
Install PyQt5 with homebrew on Mac OS X Marvericks (10.9.2)
OS X EI Capitan (10.11.6) AWS CLI installation error (python-dateutil)
Create a Python development environment on OS X Lion
I learned MNIST with Caffe and tried to draw it (MAC OS X El Capitan)