I figured out how to build tensorflow from source in centOS. This process does not require any root access and you can do it anywhere. This will save your time and no need to worry much after this.
#What to prepare:
- Java 8
- CuDNN and CUDA toolkit (assume you have install them)
I am using Bazel 0.3.2 since I found issues with Bazel in master branch.
check your JAVA_HOME since Bazel requires Java 8, you should download and install it first. This tutorial will not cover it.
$ git clone https://github.com/bazelbuild/bazel.git $ git checkout tags/0.3.2 $ cd bazel $ ./compile.sh
It takes some time and after you finished, and add the binary path into the PATH variable, in this case
This is the toughest software to build that I ever know (if you don't have any access to admin). You can download Tensorflow from github as mentioned in the website https://www.tensorflow.org/versions/r0.11/get_started/os_setup.html
$ git clone https://github.com/tensorflow/tensorflow
Then, you may need to hack the code before you can start the configuration free from issues. Go to file tensorflow/third_party/gpus/crosstool/CROSSTOOL and update
cxx_builtin_include_directory : "/usr/local/cuda/targets/x86_64-linux/include"
Run the configuration
If you are wonder to use Tensorflow in a GPU with less than 3.5 compute capabilities, you may run this command and type the compute capabilities you desired
Build with bazel
# Without GPU support $ bazel build -c opt //tensorflow/tools/pip_package:build_pip_package # To build with GPU support: $ bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package # Build whl file $ bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
pip install --upgrade /tmp/tensorflow_pkg/<your whl file>.whl