download bazel-4.5-dist.zip and follow these steps to install, newer versions of bazel don't work as of 2017-09-04
~$ cd
~$ wget https://github.com/bazelbuild/bazel/releases/download/0.4.5/bazel-0.4.5-dist.zip
~$ cd /usr/src
~$ mkdir bazel-0.4.5-dist.zip
~$ cd bazel-0.4.5-dist
~# mv ~/bazel-0.4.5-dist.zip ./
~# unzip bazel-0.4.5-dist.zip
~# ./compile.sh~$ cd ~$ wget https://github.com/bazelbuild/bazel/releases/download/0.4.5/bazel-0.4.5-dist.zip ~$ cd /usr/src ~$ mkdir bazel-0.4.5-dist.zip ~$ cd bazel-0.4.5-dist ~# mv ~/bazel-0.4.5-dist.zip ./ ~# unzip bazel-0.4.5-dist.zip ~# ./compile.shModify ~/.bashrc to activate devtoolset-2 instead of devtoolset-6. Tensorflow will not build with newer gcc, only up to gcc 4
in ~/.bashrc
source /opt/rh/devtoolset-2/enable #source /opt/rh/devtoolset-6/enableClone tensorflow into /usr/src
~$ cd /usr/src ~# git clone https://github.com/tensorflow/tensorflowConfigure tensorflow
~$ cd tensorflow ~# ./configure
in ~/.bashrc
source /opt/rh/devtoolset-2/enable #source /opt/rh/devtoolset-6/enable Clone tensorflow into /usr/src
~$ cd /usr/src
~# git clone https://github.com/tensorflow/tensorflowConfigure tensorflow
~$ cd tensorflow
~# ./configure
go to /usr/src/tensorflow/third_party/gpus/crosstool modify CROSSTOOL_clang.tpl and CROSSTOOL_nvcc.tpl add the following line to the section labeled "toolchain"
linker_flag : "-B/opt/rh/devtoolset-2/root/usr/bin"
linker_flag : "-B/opt/rh/devtoolset-2/root/usr/bin"Build tensorflow
~$ cd /usr/src/tensorflow
~# bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package~$ cd /usr/src/tensorflow ~# bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_packageCreate pip package
~# bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
~# bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkgInstall custom pip package
~# sudo pip install /tmp/tensorflow_pkg/tensorflow-1.3.0-cp34-cp34m-linux_x86_64.whl
~# sudo pip install /tmp/tensorflow_pkg/tensorflow-1.3.0-cp34-cp34m-linux_x86_64.whl