How To Install Source Tensorflow For Mac

Google provides two methods for installing TensorFlow, and the simpler option involves installing precompiled packages. This discussion presents a three-step process for installing these packages: Diskeeper support.

Installing from sources: Install TensorFlow by building a pip wheel that you then. Ubuntu/Linux 64-bit $ sudo apt-get install python-pip python-dev # Mac OS X.

  1. Install Python on your development system.
  2. Install the pip package manager.
  3. Use pip to install TensorFlow.

The second installation method involves compiling TensorFlow from its source code. This option takes time and effort, but you can obtain better performance because your TensorFlow package will take the fullest advantage of your processor’s capabilities.

Install Python and pip/pip3

TensorFlow supports development with Java and C++, but this discussion focuses on Python. Python 3 is used in the example code, but you’re welcome to use Python 2.

Python’s official package manager is pip, which is a recursive acronym that stands for “pip installs Python.” To install packages like TensorFlow, you can use pip on Python 2 systems or pip3 on Python 3 systems. Package management commands have the following format:

pip and pip3 accept similar commands and perform similar operations. For example, executing pip list or pip3 list prints all the Python packages installed on your system. The table lists this and five other commands.

Package Management Commands

Send all kinds of HTTP request w/ a full-featured visual editor & HTTP toolset. Paw advanced api tool for mac.

Command NameDescription
installInstalls a specified package
uninstallUninstalls a specified package
downloadDownloads a package, but doesn’t install it
listLists installed packages
showPrints information about a specified package
searchSearches for a package whose name or summary contains the given text

For this discussion, the most important command to know is pip install and pip3 install. But keep in mind that pip/pip3 can perform many other operations.

If you execute a TensorFlow application using a precompiled package, you may receive messages like “The TensorFlow library wasn’t compiled to use XYZ instructions, but these are available on your machine and could speed up CPU computations.” To turn off these messages, create an environment variable named TF_CPP_MIN_LOG_LEVEL and set its value to 3.

Installing on Mac OS

Many versions of Mac OS have Python already installed, but you should obtain and install a new Python package. If you visit Python Software Foundation, you see one button for Python 2 and another for Python 3. If you click one of these buttons, your browser downloads a PKG file that serves as the Python installer.

When you launch the installer, the Python installation dialog box appears. To install the package, follow these five steps:

Tensorflow
  1. In the Introduction page, click the button labeled Continue.
  2. In the Read Me page, click the button labeled Continue.
  3. In the License page, click the button labeled Continue and then click Agree to accept the software license agreement.
  4. In the Installation Type page, click Install to begin the installation process, entering your password, if necessary.
  5. When the installation is complete, click Close to close the dialog box.

If the installation completes successfully, you can run pip or pip3 on a command line. You can install TensorFlow with the following command:

This command tells the package manager to download TensorFlow, TensorBoard, and a series of dependencies. One dependency is six, which supports compatibility between Python 2 and 3. If the installation fails due to a preinstalled six package, you can fix the issue by executing the following command:

This command tells pip to install six on top of the existing installation. After this installation completes, you should be able to run pip install tensorflow without error. On the system used here, the installer stores the TensorFlow files in the /Library/Frameworks/Python.framework/Versions/<ver>/lib/python<ver>/site-packages/tensorflow directory.

Installing on Linux

Many popular distributions of Linux are based on Debian, including Ubuntu and Linux Mint. These distributions rely on the Advanced Package Tool (APT) to manage packages, which you can access on the command line by entering apt-get. This discussion explains how to install TensorFlow on these and similar operating systems.

Most Linux distributions already have Python installed, but it’s a good idea to install the full development version and pip/pip3. The following command installs both for Python 2:

Alternatively, the following command performs the installation for Python 3:

After installation completes, you should be able to execute pip or pip3 on the command line. The following command installs the TensorFlow package and its dependencies (use pip3 for Python 3):

This command installs TensorFlow, TensorBoard, and their dependencies. On an Ubuntu system, the installer stores the files in the /usr/local/lib/python<ver>/dist-packages/tensorflow directory.

Installing on Windows

For Windows users, TensorFlow’s documentation specifically recommends installing a 64-bit version of Python 3.5. To download the installer, visit Python Software Foundation, find a version of Python 3, and click the link entitled Windows x86-64 executable installer. This downloads an *.exe file that serves as the installer.

When you launch the installer, the Python setup dialog box appears. The following steps install Python on your system:

  1. Check the checkbox for adding the Python installation directory to the PATH variable.
  2. Click the link labeled Install Now.
  3. When installation finishes, click the Close button to close the installer.

After you install Python, you should be able to run pip3 on a command line. You can install TensorFlow with the following command:

The package manager downloads TensorFlow, TensorBoard, and the packages’ dependencies. On my Windows system, the installer stores the files to the C:Users<name>AppDataLocalProgramsPythonPython<ver>Libsite-packagestensorflow directory.

These instructions enable you to run TensorFlow code from the comfort of interactive Jupyter notebooks. Jupyter is itself run from within a Docker container because this ensures that you'll have all of the software dependencies you need while simultaneously preventing these dependencies from clashing with the software you already have installed on your system.

Install

  1. Open the Terminal application (like this)
  2. To install in your home directory (this is my recommended default):
    • Type cd ~ into the command-line prompt and
    • Execute the line by pressing the return key on your keyboard
  3. Retrieve all of the code for this LiveLessons by executing git clone https://github.com/the-deep-learners/TensorFlow-LiveLessons.git (if you haven't used git before, you may be prompted to install Xcode -- do it!)
  4. Install the Docker 'Stable channel' (if you are already using an older version of Docker and run into installation issues downstream, try updating to the latest version of Docker)
  5. Start Docker, e.g., by using Finder to navigate to your Applications folder and double-clicking on the Docker icon
  6. Back in Terminal, execute source TensorFlow-LiveLessons/installation/let_jovyan_write.sh so that you can write to files in the TensorFlow-LiveLessons directory from inside the Docker container we'll be creating momentarily
  7. Move into the TensorFlow-LiveLessons directory by executing cd TensorFlow-LiveLessons
  8. Build the Docker container by executing sudo docker build -t tensorflow-ll-stack . (you'll get an error if you miss the final .!)
  9. When that build process has finished, run the Docker container by executing sudo docker run -v $(pwd):/home/jovyan/work -it --rm -p 8888:8888 tensorflow-ll-stack
  10. In the web browser of your choice (e.g., Chrome), copy and paste the URL created by Docker (this begins with http://localhost:8888/?token= and should be visible near the bottom of your Terminal window)

Shutdown

You can shutdown the Jupyter notebook by returning to the Terminal session that is running it and hitting the control and c keys simultaneously on your keyboard.

Restart

You can restart the Jupyter notebook later by following steps nine and ten alone.

Bonus: Training Models with an Nvidia GPU

You don't need to train your Deep Learning models with a GPU for this course, but some of the later notebooks in these LiveLessons will run much more quickly if you do.

  1. Install an Nvidia GPU on your machine or spin up a cloud instance that includes one (typically a Tesla K80)
  2. Install CUDA and cuDNN, e.g., per the Installing CUDA Toolkit and Installing cuDNN sections of this blog post (this step may be tricky if you're relatively new to working with the Unix command line)
  3. In the TensorFlow-LiveLessons/installation/docker-stack-scripts directory:
    • run chmod 777 jupyter_notebook_config.py start*.sh
  4. Replace step eight of my Install section above with sudo docker build -f Dockerfile-gpu -t tfll-gpu-stack .
  5. Replace step nine with sudo nvidia-docker run -v $(pwd):/home/jovyan/work -it --rm -p 8888:8888 tfll-gpu-stack

Bonus: Using a Pre-Built Docker Image

Instead of building a Docker image on your own machine, Godefroy Clair is kindly hosting a pre-built Docker image. In place of the sudo docker build.. steps in the above instructions, you could instead run:

  • docker pull godot80/tf-livelessons-no-gpu:latest for the CPU-only version, or
  • docker pull godot80/tf-livelessons:latest for the Nvidia GPU version