Intel® Optimization for TensorFlow* Installation Guide

TensorFlow* is a predominantly-used machine learning framework in the deep learning arena, demanding efficient utilization of computational resources. In order to take full advantage of Intel® architecture and to extract maximum performance, the TensorFlow framework has been optimized using Intel® Math Kernel Library for Deep Neural Networks (Intel® MKL-DNN) primitives, a popular performance library for deep learning applications.For more information on the optimizations as well as performance data, see this blog post TensorFlow* Optimizations on Modern Intel® Architecture .

Anaconda* has now made it convenient for the AI community to enable high-performance-computing in TensorFlow library. Starting from TensorFlow v1.9, Anaconda has and will continue to build TensorFlow using Intel® Math Kernel Library for Deep Neural Networks (Intel® MKL-DNN) primitives to deliver maximum performance in your CPU.

Quick Links

Anaconda

*Supports Py27 and Py36

PIP Wheels

Docker Containers

Build from source

Install the latest Intel® Optimization for TensorFlow* from Anaconda* Cloud

Available for Linux*, Windows*, MacOS*

TensorFlow* version: 1.12

Installation instructions:

Linux

Open Anaconda prompt and use the following instruction

conda install tensorflow

In case your anaconda channel is not the highest priority channel by default(or you are not sure), use the following command to make sure you get the right TensorFlow with Intel optimizations

conda install -c defaults tensorflow

Windows and MacOS

Open Anaconda prompt and use the following instruction

conda install tensorflow-mkl

(or)

conda install tensorflow-mkl -c defaults

Besides the install method described above, Intel Optimization for TensorFlow is distributed as wheels, docker images and conda package on Intel channel. Follow one of the installation procedures to get Intel-optimized TensorFlow.

 

Note: All binaries distributed by Intel were built against the TensorFlow v1.11 tag in a centOS container with gcc 4.8.5 and glibc 2.17 with the following compiler flags (shown below as passed to bazel*)

--cxxopt=-D_GLIBCXX_USE_CXX11_ABI=0 --copt=-march=corei7-avx --copt=-mtune=core-avx-i --copt=-O3 

Install the latest Intel® Optimization for TensorFlow* from Intel Channel

Available for Linux*

TensorFlow* version: 1.11

Installation instructions:

Open Anaconda prompt and use the following instruction. Available for Python 2.7 and 3.6.

conda install tensorflow -c intel

Get Intel® Optimization for TensorFlow* from Intel® Distribution for Python

Available for Linux*

TensorFlow* version: 1.11

Installation instructions:

Open Anaconda prompt and use the following instruction. Available for Python 2.7 and 3.6.

conda create -n IDP intelpython3_full -c intel

(or)

conda create -n IDP intelpython2_full -c intel

Install the Intel® Optimization for TensorFlow* Wheel Into an Existing Python* Installation Through PIP

Available for Linux*

TensorFlow version: 1.11

Installation instructions:

Run the below instructions to install the wheel into an existing Python* installation, preferably Intel® Distribution for Python*:

Python 2.7

pip install https://storage.googleapis.com/intel-optimized-tensorflow/tensorflow-1.11.0-cp27-cp27mu-linux_x86_64.whl 

Python 3.4

pip install https://storage.googleapis.com/intel-optimized-tensorflow/tensorflow-1.11.0-cp34-cp34m-linux_x86_64.whl 

Python 3.5

pip install https://storage.googleapis.com/intel-optimized-tensorflow/tensorflow-1.11.0-cp35-cp35m-linux_x86_64.whl

Python 3.6

pip install https://storage.googleapis.com/intel-optimized-tensorflow/tensorflow-1.11.0-cp36-cp36m-linux_x86_64.whl 

Edit 10/18/2018: Wheel paths have been updated to 1.11

Warning on ISA above AVX2:

"The TensorFlow library was not compiled to use <Instruction set> instructions, but these are available on your machine and could speed up CPU computations."

This warning can be ignored since Intel MKL-DNN library with which the TensorFlow is compiled utilizes the latest Instruction sets available in your processor to perform compute-intensive operations.

Older CPUs may not support this version of TensorFlow and may result in "Illegal instruction (core dumped)" error.

Install the Intel® Optimization for TensorFlow* Docker Images Into an Existing Python* Installation

Obtaining and Running the Containers

These docker images are all published at http://hub.docker.com in intelaipg/intel-optimized-tensorflow namespace and can be pulled with the following command:

 

docker pull docker.io/intelaipg/intel-optimized-tensorflow:<tag>

 

For example, to run the python 2.7 data science container directly, simply

docker run -it -p 8888:8888 intelaipg/intel-optimized-tensorflow

And then go to your browser on http://localhost:8888/


For those who want to navigate through the browser, follow the link

https://hub.docker.com/r/intelaipg/intel-optimized-tensorflow/

Available Container Configurations 

The following tags/configurations are available:

Docker Container Configurations
ConfigurationTags
Python 2.7 with jupyter and sample notebooks

latest

latest-mkl

1.11.0-mkl

1.11.0

Python 2.7 with TensorFlow development toolchain

latest-devel

latest-devel-mkl

1.11.0-devel-mkl

1.11.0-devel

Python 3.5 with jupyter and sample notebooks

latest-py3

latest-mkl-py3

1.11.0-mkl-py3

1.11.0-py3

Python 3.5 with TensorFlow development toolchain

latest-devel-py3

latest-devel-mkl-py3

1.11.0-devel-mkl-py3

1.11.0-devel-py3

To get the latest Release Notes on Intel-optimized TensorFlow, please refer this article

Build TensorFlow from Source with Intel® MKL

Building TensorFlow from source is not recommended. However, if instructions provided above do not work due to unsupported ISA, you can always build from source.

Building TensorFlow from source code requires Bazel installation, refer to the instructions here, Installing Bazel.

Installation instructions:

  1. Run "./configure" from the TensorFlow source directory
  2. Execute the following commands to create a pip package that can be used to install the optimized TensorFlow build.
    • PATH can be changed to point to a specific version of GCC compiler:
      export PATH=/PATH//bin:$PATH
      
    • LD_LIBRARY_PATH can also be to new:
      export LD_LIBRARY_PATH=/PATH//lib64:$LD_LIBRARY_PATH
      
    • Set the flag to build TensorFlow with Intel® Math Kernel Library (Intel® MKL) and pass appropriate Instruction sets you want to compile the library with: 

Flags set in the command below will add AVX, AVX2 and AVX512 instructions which will result in "illegal instruction" errors when you use older CPUs. If you want to build on older CPUs, set the instruction flags accordingly

bazel build --config=mkl -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mavx512f --copt=-mavx512pf --copt=-mavx512cd --copt=-mavx512er //tensorflow/tools/pip_package:build_pip_package

        3. Install the optimized TensorFlow wheel

     bazel-bin/tensorflow/tools/pip_package/build_pip_package ~/path_to_save_wheel
     pip install --upgrade --user ~/path_to_save_wheel /<wheel_name.whl>

Archived Wheels

Version

Wheels(2.7, 3.5, 3.6)

1.6

https://anaconda.org/intel/tensorflow/1.6.0/download/tensorflow-1.6.0-cp27-cp27mu-linux_x86_64.whl

(or)

*/tensorflow-1.6.0-cp35-cp35mu-linux_x86_64.whl

(or)

*/tensorflow-1.6.0-cp36-cp36mu-linux_x86_64.whl

1.9

https://storage.googleapis.com/intel-optimized-tensorflow/tensorflow-1.9.0-cp27-cp27mu-linux_x86_64.whl

https://storage.googleapis.com/intel-optimized-tensorflow/tensorflow-1.9.0-cp35-cp35m-linux_x86_64.whl

https://storage.googleapis.com/intel-optimized-tensorflow/tensorflow-1.9.0-cp36-cp36m-linux_x86_64.whl

1.10

https://storage.googleapis.com/intel-optimized-tensorflow/tensorflow-1.10.0-cp27-cp27mu-linux_x86_64.whl

https://storage.googleapis.com/intel-optimized-tensorflow/tensorflow-1.10.0-cp35-cp35m-linux_x86_64.whl

 https://storage.googleapis.com/intel-optimized-tensorflow/tensorflow-1.10.0-cp36-cp36m-linux_x86_64.whl

 

 

For more complete information about compiler optimizations, see our Optimization Notice.

20 comments

Top
Bonventre, Gaspare's picture

Would it be possible to get a wheel for a Windows Machine?

Louis, Jerry's picture

Hi There,

I tried installing the conda install tensorflow the  everything have to seemed to work fine. I tested using the python example. But I'm after the c++ api of the Intel optimised tensorlfow, with the above installation how do i go about running an example like this:

#include <stdio.h>
#include <tensorflow/c/c_api.h>

int main() {
  printf("Hello from TensorFlow C library version %s\n", TF_Version());
  return 0;
}

I cant seem to find the include files with the above installation?

Will I need to build tensorflow from source?

Am I missing something here completely? Any help would be much appericated, thanks.

 

 

 

 

George P.'s picture

Hi,

Intel Optimiziations for TensorFlow sounds super useful.

I haven't tried it yet as I see there's Linux support only (unless I build from source).
I'm using OSX and I was wondering:

  1. Will there be an Intel TensoFlow whl for OSX at any point ? (If so, when ?)
  2. As far as I understand this runs on the CPU. Would it be possible at any point to use TensorFlow with GPU acceleration on Intel GPUs (e.g. Intel Iris Pro ) ? (If so, when ?)

Thank you,
George

Phillip O.'s picture

I am unable to complete Bazel with the following error:

ERROR: /root/.cache/bazel/_bazel_potero/bb908902e7a4c1214e822194ebe85aca/external/double_conversion/BUILD.bazel:12:1: C++ compilation of rule '@double_conversion//:double-conversion' failed (Exit 1)
gcc: error: unrecognized command line option '-mavx512f'
gcc: error: unrecognized command line option '-mavx512pf'
gcc: error: unrecognized command line option '-mavx512cd'
gcc: error: unrecognized command line option '-mavx512er'
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 6.517s, Critical Path: 1.78s
INFO: 3 processes: 3 local.
FAILED: Build did NOT complete successfully

Any help would be aoppreciated.

Preethi: You could probably be using an older gcc(<4.9) version and trying to pass avx512 flags. Please check the GCC documentation for you version to see if these flags are available.

Sagalovsky, Benjamin's picture

Thank you, Preethi, but the original question still stands: will this speed up Tensorflow on my Core  i7-7500U CPU, or are those optimizations only effective for high-end Xeon processors? Thanks!

Preethi: Intel MKL-DNN, which is used to build the optimized TensorFlow supports Core processors. Refer the System Requirements section in the GitHub page here: https://github.com/intel/mkl-dnn

 

Sagalovsky, Benjamin's picture

Hello,

I have a humble laptop with an Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz, running Windows 10 (oh, what a shame!), Anaconda and Jupyter Lab. Would I benefit at all of installing tensorflow-mkl? If there are any benefits, are there some pre-requisites/pre-installs that I would need to do?

In more general terms, what are the processors that would benefit from this install and from the MKL-DNN library as such?

Preethi Venkatesh: Hi Benjamin, The new version of  default TensorFlow (1.9) from the Anaconda Channel is build using MKL-DNN optimizations and is available for download now. just do a "conda install tensorflow". No other prerequisites needed.

Thanks!

Ben

Cooksey, Robert (Intel)'s picture

Is this method still relevant? https://software.intel.com/en-us/articles/using-intel-distribution-for-python-with-anaconda

It avoids the pip <-> conda conflict.

 

 

Pradyumna's picture

Method 2 doesn't work for me on my MacBook. I get the following error:

Solving environment: failed

UnsatisfiableError: The following specifications were found to be in conflict:
  - intelpython3_core
  - tbb4py
  - tensorflow
Use "conda info <package>" to see the dependencies for each package.

Can somebody please help?

 

Pradyumna's picture

I tried method 2, but I get the following error:

Solving environment: failed

UnsatisfiableError: The following specifications were found to be in conflict:
  - intelpython3_core
  - tbb4py
  - tensorflow
Use "conda info <package>" to see the dependencies for each package.

Can somebody please help?

Cai, Jason's picture

Thanks for the update about details of compiling TF+MKL from source with TF r1.6.

I am confused when doing "bazel build ...". From https://www.tensorflow.org/performance/performance_guide#tensorflow_with_intel_mkl_dnn, it says:

./configure
# Pick the desired options
bazel build --config=mkl --config=opt //tensorflow/tools/pip_package:build_pip_package

It's quite different from the bazel build cmds here.

Could you please tell me the reason why '--copt="-DEIGEN_USE_VML"' is needed?

Thanks.

Pages

Add a Comment

Have a technical question? Visit our forums. Have site or software product issues? Contact support.