Mac Tensorflow Library Wasn't Compiled To Use

  1. Mac Tensorflow Library Wasn't Compiled To Use Pdf
  2. Mac Tensorflow Library Wasn't Compiled To Use File

Jun 13, 2017 Installing TensorFlow on Mac OX X with GPU support. Iwatobipen programming chemoinfo, programming, python, RDKit. Yesterday, I tried to install tensorflow-gpu on my mac. The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. Well, it lets you create a version of TensorFlow with custom options. For example, if you got the “The TensorFlow library wasn’t compiled to use SSE4.1 instructions” warnings while running the train.py script, you can compile a version of TensorFlow that enables these instructions. To build TensorFlow for Mac, run the following from Terminal.

These instructions were inspired by Mistobaan's gist, ageitgey's gist, and mattiasarro's tutorial.

Background

I always encountered the following warnings when running my scripts using the precompiled TensorFlow Python package:

I have a TensorFlow model to test a wide-n-deep neural network, but I can't get it to run on my windows machine because of a bug in the TensorFlow Library. Now I'm having to resort to Google Cloud. I compiled a small Bash script for Mac (easily can be ported to Linux) to retrieve all CPU features and apply some of them to build TF. Im on TF master and use kinda often (couple times in a month). The TensorFlow library wasn' t compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. Clone via HTTPS Clone with Git or checkout with SVN using the repository’s web address.

I realized I can make these warnings go away by compiling from source, in addition to improve training speed. It was not as easy and straightforward as I thought, but I finally succeeded in creating a working build. Here I outline the steps I took, in the hopes it may benefit those who have encountered similar challenges.

Apr 16, 2019  When running your project, you get errors like “The TensorFlow library wasn’t. Compiled to use SSE4.2 instructions, but these are available on your machine. Could speed up CPU computations.” This means you need to run configure again and set the proper flags that you see in the message. I added “-mavx -mavx2 -mfma -msse4.2”. The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. I saw other links and it doesn't solve my question.

Machine setup

Hardware

  • Model: MacBook Pro (Retina, 15-inch, Mid 2014)
  • Processor: 2.5 GHz Intel Core i7
  • Memory: 16 GB 1600 MHz DDR3
  • Graphics: Intel Iris Pro 1536 MB RAM + NVIDIA GeForce GT 750M 2048 MB RAM

Software

  • OS: macOS Sierra 10.12.6
  • TensorFlow version: 1.3.1
  • Python version: 3.6.2 (conda)
  • Bazel version: 0.6.0-homebrew
  • CUDA/cuDNN version: 8.0/6.0

Prerequisites

macOS Sierra (10.12)

I tested on macOS Sierra 10.12. It may also work on Yosemite (10.10) and El Capitan (10.11), but I have not verified.

Xcode Command-Line Tools

I successfully compiled using Xcode 8.2.1 (Refer to http://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html#system-requirements).

Disable SIP (System Integrity Protection) on Mac

For some reason I had to disable SIP in order for bazel build to build the TensorFlow pip package successfully. For security reasons, remember to re-enable SIP after your build.

Steps

Mac Tensorflow Library Wasn't Compiled To Use Pdf

Note: Many steps were based on https://www.tensorflow.org/install/install_sources ; I just happened to have a slightly different order that worked out for me.

  • Install homebrew
  • Install bazel
  • Install conda (I wanted a Python environment that will not mess with system Python. I downloaded Miniconda for Python 2.7 and intended to create a Python 3.6 environment)
  • Create and activate Python 3.6 environmentAlternatively, you can do:
  • Verify that the following packages are installed:
    • six
    • numpy
    • has to be at least 1.13 so you don't get a ModuleNotFoundError: No module named 'numpy.lib.mixins' error later on during bazel build
    • wheel
  • Install CUDA support prerequisites
    • Install GNU coreutils and swig
    • Refer to this for more detailed CUDA installation instructions.
    • Install CUDA Toolkit 8.0
    • Install cudNN 6.0
    • Set environment variable DYLD_LIBRARY_PATH
  • Clone the TensorFlow repository (instructions): be sure to checkout the r1.3 release
  • Configure the installationMy configure settings (Enter N for CUDA support if you do not want CUDA support or do not have a NVIDIA GPU):
  • Comment out linkopts = ['-lgomp'], (line 112) in tensorflow/third_party/gpus/cuda/BUILD.tpl (Refer to https://medium.com/@mattias.arro/installing-tensorflow-1-2-from-sources-with-gpu-support-on-macos-4f2c5cab8186)
  • Build the pip package (reference: https://stackoverflow.com/questions/41293077/how-to-compile-tensorflow-with-sse4-2-and-avx-instructions). It took around 35 minutes on my MacBook Pro.
  • Refer to https://github.com/tensorflow/tensorflow/issues/6729 if you run into any other problems
  • Build the wheel (.whl) file
  • Install the pip package
  • Validate your installation (instructions)
    • Change directory to any directory on your system other than the tensorflow subdirectory from which you ran ./configure
    • Invoke python interactive shell
    • Type in the following scriptIf you have a supported NVIDIA CUDA GPU, the script should run without a problem and display something similar to this:

Have fun training your models!

If you’re the file’s owner, you’re likely not a security risk.Neverchoose an access level for yourself other than Read & Write without being absolutely sure of what you’re doing, because you can potentially prevent yourself from accessing or deleting the file in the future!For example, if you simply want to lock an item to prevent changes being made, don’t set your Ownership permission to Read Only. (Instead, select the Locked check box in the General section of the Info dialog instead. How to access library on mac air

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:

  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

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:

Mac Tensorflow Library Wasn't Compiled To Use File

  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.

How to delete old photo library on mac. 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.