Learning TensorFlow from scratch requires various knowledge and expensive computers, but in this tutorial, we will remove those assumptions and build a TensorFlow environment based on the feeling of "** I will try to move it for the time being **". I will do it.
If you want to run TensorFlow on python3.7 or above, the following article will be helpful. Reference: A story about building a Tensorflow environment with MacOS Mojave & Python3.7
If you want to run it on macOS Mojave, the following article will be helpful. Reference: Enable python3 system using pyenv on macOS Mojave
--Those who want to start TensorFlow --For those who want to run TensorFlow for the time being --Those who want to build an environment with the minimum configuration
--1. Install Xcode Command Line Tools ―― 2. Install Homebrew --3. Installation of pyenv-virtualenv ―― 4. Build a Python environment for TensorFlow --5. Install pip ―― 6. Installation of TensorFlow
Command Line Tools is part of Apple's integrated development environment for MacOS / MacOSX. It includes the GCC compiler, etc. required to install UNIX-based applications. If you have an Apple ID, you can also download it at Apple Developer. ** Please [Get] Xcode from the App Store (https://itunes.apple.com/jp/app/xcode/id497799835?mt=12) before installing Command Line Tools. ** **
This is a prerequisite for Homebrew to be installed later. Install Xcode Command Line tools.
If you are asked to grant a license, please accept the license agreement.
$ xcode-select --install xcode-select: error: command line tools are already installed, use "Software Update" to install updates
HomeBrew is a package manager provided for MacOS / MacOSX. You can manage the software from the command line. Generally, when installing software, you need to manually obtain the software executable file or manually build the source code, and HomeBrew does a series of these tasks automatically.
Homebrew Copy and execute the following command described on the official website.
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
If the output is as below, Homebrew installation is complete.
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" ... ... ==> Installation successful! ==> Homebrew has enabled anonymous aggregate user behaviour analytics. Read the analytics documentation (and how to opt-out) here: https://docs.brew.sh/Analytics.html ==> Next steps: - Run `brew help` to get started - Further documentation: https://docs.brew.sh
pyenv is a python version control system. You can switch the Python version. pyenv-virtualenv is a Pyenv plugin for managing your Python environment.
Install pyenv with Homebrew.
$ brew install pyenv
Install pyenv-virtualenv with Homebrew.
$ brew install pyenv-virtualenv
Display and check the Python version list.
$ pyenv install -l
Install Python 3.6.0 and refresh Shims.
$ pyenv install 3.6.0 ... ... $ pyenv rehash
Create a Python environment for TensorFlow.
$ pyenv virtualenv 3.6.0 TensorFlow $ pyenv rehash
Specify the Python environment created for TensorFlow.
$ pyenv global TensorFlow
Check the Python environment you specified for TensorFlow.
$ python --version Python 3.6.0
pip (Pip javax Packages) is a Python package management system. If you want to use third party libraries with python, you can manage those packages with pip.
Install and update the Python plugin management tool (pip).
$ sudo easy_install pip $ sudo easy_install --upgrade six $ sudo pip install --upgrade pip
Install TensorFlow with pip.
$ pip3 install --upgrade tensorflow
Check the operation of TensorFlow.
$ python >>> import tensorflow as tf >>> hello = tf.constant('Hello, TensorFlow!') >>> sess = tf.Session() >>> print(sess.run(hello)) Hello, TensorFlow!
If an error is output as shown below, please also refer to the link below.
this TensorFlow binary was not compiled to use: AVX2 FMA
Exit with exit ().
Next time I will play with TensorFlow.
2017/8/21 Added the items to be installed by pyenv.