OS: CENTOS 6.8 (No root access)
GCC: locally installed 5.2.0 (Cluster default is 4.4.7)
Bazel: 0.4.0-2016-11-06 (@fa407e5)
You should be able to modify the script (buildtf.sh) below to do these steps automatically, but I list out details here as well.
Installing Java Locally:
Follow this Tutorial or download prefered version of JDK 8.0 and set proper environment variables as described in the tutorial.
Compiling Bazel, Compiling and Installing Tensorflow:
Note: After change the linker line to your local or module GCC, If you get errors about finding ld, or other executables
that are stored in
/usr/bin here is the work around I used (it isn't pretty and you might not need it, but just in case):
Copy your compiler directory (
/opt/gcc/5.2.0) to a local directory that you have permissions to modify.
cp `which ld` /opt/gcc/5.2.0/bin/ld (repeat for any command listed in the crosstools that doesn't already reside in your gcc /bin directory)
Note2: I downloaded a newer release of bazel and tensorflow as noted above and there are fewer changes required in the latest versions of the crosstool then described in the tutorial.
modify /tensorflow/third_party/gpus/crosstool/CROSSTOOL.tpl as described in tutorial above
modify /tensorflow/third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc.tpl as described in tutorial above. I did not change the first line: #!/usr/bin/env python (but the tutorial does!)
Again these steps led to the below error which took me forever to get past:
Getting Past GBLICXX_3.4.18 Error:
As described in gbkedar's comment from Jul 12. You have to find this file:
But, until the compile fails this file is harder to find. (The buildtf.sh re-runs the compile after modifying the file after the first failure). The failure creates the shortcut in the
/tensorflow directory. I was running into issues re-attempting the compile and had to run
./configure almost everytime. Therefore, I had to find this file before the first failure of my compile attempt. The file should be located somewhere similar to this after running
./configure from the
If you have several hashes, check the files that were modified at the time corresponding to your
As described in the error link above, search for ctx.action and add
env=ctx.configuration.default_shell_env, at the bottom of the call like so:
if args: ctx.action( inputs=inputs, outputs=ctx.outputs.outs, arguments=args + import_flags + [s.path for s in srcs], executable=ctx.executable.protoc, mnemonic="ProtoCompile", env=ctx.configuration.default_shell_env, )
You will then likely hit
error trying to exec 'as': execvp: No such file or directory. Since I am a self-confessing linux noob, you have to use the few tricks you know as much as possible(I didn't follow gbkedar's 2nd comment):
cp `which as` /opt/gcc/5.2.0/bin/as
After this change, tensorflow finally compiled successfully for me!
Building .whl file:
Going back to our tutorial I ran this command:
and received the
bdist_wheel not found error... I solved this by using pip install to install a new version of wheel locally:
pip install --target=/home/thpaul/python27-packages wheel
and then added that directory to my $PYTHONPATH variable:
Re-running the command builds the proper .whl file which you can install via pip.
Hope this helps anyone trying to compile tensorflow from source!