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 on Linux OS. 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. If you are using conda package manager to manage your environments and packages, all you have to do is just install the TensorFlow package from Anaconda.org into your virtual environments.
Additionally, Intel® Optimization for latest TensorFlow* version is distributed as Wheels and Docker images for Python 2.7, 3.5 and 3.6.
Install the latest Intel® Optimization for TensorFlow* from Anaconda* Cloud
TensorFlow* version: 1.11
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 anaconda tensorflow
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
TensorFlow* version: 1.11
Open Anaconda prompt and use the following instruction. Available for Python 2.7 and 3.6.
conda install tensorflow -c intel
Install the Intel® Optimization for TensorFlow* Wheel Into an Existing Python* Installation Through PIP
Available for Linux* OS
TensorFlow version: 1.11
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
Available Container Configurations
The following tags/configurations are available:
|Python 2.7 with jupyter and sample notebooks|
|Python 2.7 with TensorFlow development toolchain|
|Python 3.5 with jupyter and sample notebooks|
|Python 3.5 with TensorFlow development toolchain|
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.
- 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.
PATHcan be changed to point to a specific version of GCC compiler:
LD_LIBRARY_PATHcan also be to new:
- 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
pip install --upgrade --user ~/path_to_save_wheel /<wheel_name.whl>
Wheels(2.7, 3.5, 3.6)