Building TensorFlow 1.4 from Source to Support Intel CPU w/ Anaconda

Building TensorFlow 1.4 from Source to Support Intel CPU w/ Anaconda

References:

  1. https://www.tensorflow.org/install/install_sources#ConfigureInstallation
  2. https://stackoverflow.com/questions/41293077/how-to-compile-tensorflow-with-sse4-2-and-avx-instructions#comment81255824_47146118
  3. Pre-built wheels: https://github.com/lakshayg/tensorflow-build
  4. More pre-built wheels: https://github.com/yaroslavvb/tensorflow-community-wheels
  5. https://stackoverflow.com/questions/40373686/freeze-graph-py-throws-an-error-during-build/40374431#40374431
  6. https://stackoverflow.com/questions/41293077/how-to-compile-tensorflow-with-sse4-2-and-avx-instructions

Environment:

Software Set Up:

  1. Install Anaconda: https://docs.anaconda.com/anaconda/install/linux
  2. Install git sudo apt-get install git-core
  3. Create a virtualenv conda create -n tensorflow python=3.6
  4. Activate virtualenv activate source tensorflow
  5. Install TensorFlow requirements
    a. conda install six numpy wheel
  6. Install Bazel https://docs.bazel.build/versions/master/install.html#mac-os-x
  7. Clone TensorFlow repository: git clone https://github.com/tensorflow/tensorflow
    a. Choose the branch git checkout r1.4 <-- There seems to be a problem with r1.4 during the build process. Ended up using the master branch as of Nov 16, 2017 git checkout master
  8. Determine python binary location which python
    Sample output: /home/ronson/anaconda3/envs/tensorflow/bin/python
  9. Start build process for TensorFlow
    a. cd tensorflow
    b. ./configure
    c. /home/ronson/anaconda3/envs/tensorflow/lib/python3.6/site-packages
    d. bazel build --copt=-march=native --config="opt,MKL" -k //tensorflow/tools/pip_package:build_pip_package --local_resources 4096,.5,1.0 --verbose_failures
    e. Create the wheel ./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
    f. This was the wheel that I created: pip install /tmp/tensorflow_pkg/tensorflow-1.4.0-cp36-cp36m-linux_x86_64.whl

Object Detection Installation

  1. https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md

Run Object Detection Python Notebook

  1. Set up Kernel for virtualenv
    a. http://help.pythonanywhere.com/pages/IPythonNotebookVirtualenvs
  2. Change to the research folder cd /home/ronson/models/research
  3. Run jupyter notebook jupyter notebook
  4. Open the object_detection_tutorial.ipynb in ./models/research/object_detection
  5. Change the kernel: Kernel -> Change Kernel -> tensorflow
  6. As of Nov 11, 2017, the default MODEL_NAME in the notebook doesn't work
    https://github.com/tensorflow/models/issues/2773
    a. Change the MODEL__NAME to ssd_mobilenet_v1_coco_11_06_2017