TensorFlow 1.x Deep Learning Cookbook
上QQ阅读APP看书,第一时间看更新

Getting ready

At present, XLA is not included in the binary distributions of TensorFlow. One needs to build it from source. To build TensorFlow from source, knowledge of LLVM and Bazel along with TensorFlow is required. TensorFlow.org supports building from source in only MacOS and Ubuntu. The steps needed to build TensorFlow from the source are as follows (https://www.tensorflow.org/install/install_sources):

  1. Determine which TensorFlow you want to install--TensorFlow with CPU support only or TensorFlow with GPU support.
  2. Clone the TensorFlow repository:
git clone https://github.com/tensorflow/tensorflow 
cd tensorflow
git checkout Branch #where Branch is the desired branch
  1. Install the following dependencies:
    • Bazel
    • TensorFlow Python dependencies
    • For the GPU version, NVIDIA packages to support TensorFlow
  1. Configure the installation. In this step, you need to choose different options such as XLA, Cuda support, Verbs, and so on:
./configure 
  1. Next, use bazel-build:
  2. For CPU only version you use:
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
  1. If you have a compatible GPU device and you want the GPU Support, then use:
bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
  1. On a successful run, you will get a script, build_pip_package.
  2. Run this script as follows to build the whl file:
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

  1. Install the pip package:
sudo pip install /tmp/tensorflow_pkg/tensorflow-1.1.0-py2-none-any.whl

Now you are ready to go.