Intel® Optimization for TensorFlow* Installation Guide

This is a computer translation of the original content. It is provided for general information only and should not be relied upon as complete or accurate.

Sorry, we can't translate this content right now, please try again later.

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.

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 anaconda

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.12.0 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*)

Ensure numpy, keras-applications, keras-preprocessing, pip, six, wheel, mock packages are installed in the Python environment where TensorFlow is being built and installed.

Clone the TensorFlow source code and checkout 1.12 branch

git clone https://github.com/tensorflow/tensorflow
git checkout r1.12

Run "./configure" from the TensorFlow source directory

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 compiler flags support by the GCC on your machine to build TensorFlow with Intel® Math Kernel Library (Intel® MKL). Ensure appropriate "march" and "mtune" flags are set. Refer the gcc online docs to know the flags supported by your GCC version.

Alternatively, set appropriate "Instruction sets" flags 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

20 comments

I tried installing the conda installtensorflow 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:

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.

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.

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.