Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Getting started with Tensor Flow (Installation)

Getting Started

Background Reading: Reference:

Installed, via pip, the python bindings for tensorflow (for CPU, not GPU/CUDA)

sudo pip install

This did a bunch of things, including uninstalling numpy 1.6 (from disutils?) and re-installing numpy (via pip?). Hope that doesn't break shit. Probably should have done this in a virtualenv... While this did install fine, I can't import it because it used a binary that derives from a version of glibc that is newer than the one I have installed. I'd rather not upgrade glibc, so I'll try to compile myself. Including error below so Google can find it.

>>> import tensorflow
    _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: /lib/x86_64-linux-gnu/ version `GLIBC_2.17' not found (required by /usr/local/lib/python2.7/dist-packages/tensorflow/python/

So, now I'm faced with two options: Upgrade my glibc to 2.17 just for tensorflow, or rebuild from source so that my build of tensorflow is linked to my installed version of glibc (2.15). I'm choosing to build from source, which doesn't look too bad.

Building from source

Going to try to keep it simple (no GPU support). Following instructions from the docs

Clone the tensorflow and bazel repositories.

$ git clone --recurse-submodules
$ git clone

To get Bazel built, I had to install java 8. This is my guess at least, because compiling with Java 7 gives the following error:

java.lang.AssertionError: java.lang.NullPointerException

Let's install Java 8 first (probably should do this anyway for other projects):

$ sudo add-apt-repository ppa:webupd8team/java && sudo apt-get update
$ sudo apt-get install oracle-java8-installer
$ sudo update-alternatives --config java
... selected java 8 from the menu, now system java points to java 8
$ java -version
java version "1.8.0_66"

Compile bazel -- with JAVA_HOME updated to point to jdk 8

$ cd bazel
$ JAVA_HOME=/usr/lib/jvm/java-8-oracle/ ./

Turns out there's a bug for debian wheezy that causes the build to fail.

location R_X86_64_PC32 against symbol `PostException(JNIEnv_*, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value

There's a fix, which involves removing the -fPIC flags from the compiler. I commented out line 162, 275, 383 in tools/cpp/CROSSTOOL. This did not work in the end, so I tried checking out a previous 1.0 version via git (based on the previously mentioned github issue): git checkout ecd4ec

Now, building appears to work:

$ JAVA_HOME=/usr/lib/jvm/java-8-oracle/ ./
$ ./output/bazel --help (this runs fine)

Now, let's build tensorflow

$ cd tensorflow
$ ../bazel/output/bazel build

... this won't build due to an error

Turns out I can just intall Bazel 0.1.0 -- oops.

Copy link

off99555 commented Jul 4, 2016

I'm searching for how to fix glibc2.17 for tensorflow problem and found your gist file here. Is this a fix or a complaint? I'm suspecting because the last paragraph isn't telling how to succeed.

Copy link

booherbg commented Jun 27, 2017

@off99555 -- sorry about that. I wish github had a way of notifying on gist comments.

I ended up going a completely different route. I don't think I was ultimately successful, but this path was abandoned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment