Build Tensorflow from Source with Swig and Bazel without Root

Sometimes we may need to install Tensorflow from source without root access to the server, such as a cluster environment. This is even more true when you need to configure Tensorflow with your own environment: e.g., different Cuda and CuDNN versions. This post describes how to compile Bazel, Swig from source, and use them to compile Tensorflow.

Step 1: Compile Bazel from source

Step 2: Compile Swig from source

Step 3: Compile Tensorflow


Troubleshooting

Error 1: protoc failed, version `GLIBCXX_3.4.18′ not found (solution)

Error 2: image_ops_gpu.cu buld error

solution:

This error occurs when I was trying to compile v1.2.0. Instead, I compiled from the master (commit: 7c10b24de3cb2408441dfd98e1a1a1e8f43f3a7d) and the problem was resolved.


Revision History
Jun 19, 2017: updated for TF 1.2.0

2 Replies to “Build Tensorflow from Source with Swig and Bazel without Root”

  1. Just for ref, if your CPU support AVX2/SSE/… –Tensorflow would remind you of that in its output, use the following to compile to max its CPU performance:

    “`code
    bazel build -c opt –copt=-mavx –copt=-mavx2 –copt=-mfma –copt=-mfpmath=both –copt=-msse4.2 –config=cuda -k //tensorflow/tools/pip_package:build_pip_package
    “`

    If you don’t use GPU/CUDA, remove ‘ –config=cuda’

Leave a Reply

Your email address will not be published. Required fields are marked *