Build and install TensorFlow from source with MKL DNN support and AVX enabled
Do not miss this exclusive book on Binary Tree Problems. Get it now for free.
Reading time: 15 minutes | Installation time: 20 minutes
In this guide, we will walk you through building and installing TensorFlow from source with support for MKL DNN and with AVX enabled.
Step 1: Clone the source
To get started, you need to clone the source code of TensorFlow:
git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow
Step 2: Chose your version
Currently, you are on the development branch. You can, optionally, switch to a release branch such as 1.11:
git checkout r1.11
Step 3: Install Bazel
Follow the following commands one by one to successfully install TensorFlow:
sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python
wget https://github.com/bazelbuild/bazel/releases/download/0.18.1/bazel-0.18.1-installer-linux-x86_64.sh
chmod +x bazel-0.18.1-installer-linux-x86_64.sh
./bazel-0.18.1-installer-linux-x86_64.sh --user
export PATH="$PATH:$HOME/bin"
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update && sudo apt-get install oracle-java8-installer
echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
sudo apt-get update && sudo apt-get install bazel
Step 4: Configure the build
./configure
Follow the instructions carefully
Step 5: Build the pip wheel file
bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma
--copt=-mfpmath=both --copt=-msse4.1 --copt=-msse4.2 --config=cuda -k
//tensorflow/tools/pip_package:build_pip_package
Step 6: Build with pip
bazel-bin/tensorflow/tools/pip_package/
build_pip_package /tmp/tensorflow_pkg
sudo pip install /tmp/tensorflow_pkg/
tensorflow-1.11.0-cp27-cp27mu-linux_x86_64.whl
You have installed TensorFlow with MKL DNN support and AVX enabled
You have an efficient version of TensorFlow and you can get started by developing models in TensorFlow
Sign up for FREE 3 months of Amazon Music. YOU MUST NOT MISS.