QBoard » Artificial Intelligence & ML » AI and ML - Tensorflow » Error while importing Tensorflow in Python 2.7 in Ubuntu 12.04. 'GLIBC_2.17 not found'

Error while importing Tensorflow in Python 2.7 in Ubuntu 12.04. 'GLIBC_2.17 not found'

  • I have installed the Tensorflow bindings with python successfully. But when I try to import Tensorflow, I get the follwoing error.

    ImportError: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.17' not found (required by /usr/local/lib/python2.7/dist-packages/tensorflow/python/_pywrap_tensorflow.so)
    I have tried to update GLIBC_2.15 to 2.17, but no luck. This post was edited by Jainew Nanda at September 3, 2020 4:27 PM IST
      September 3, 2020 4:26 PM IST
    0
  • I had the same problem, so googling I made these steps:

    $ sudo pip install --upgrade virtualenv
    $ virtualenv --system-site-packages ~/tensorflow
    $ cd ~/tensorflow
    $ source bin/activate
    $ pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl
    $ cd /tmp
    $ wget http://launchpadlibrarian.net/137699828/libc6_2.17-0ubuntu5_amd64.deb
    $ wget http://launchpadlibrarian.net/137699829/libc6-dev_2.17-0ubuntu5_amd64.deb
    $ mkdir libc6_2.17
    $ cd libc6_2.17
    $ ar p ../libc6_2.17-0ubuntu5_amd64.deb data.tar.gz | tar zx
    $ ar p ../libc6-dev_2.17-0ubuntu5_amd64.deb data.tar.gz | tar zx
    $ cd -
    $ LD_LIBRARY_PATH=/tmp/libc6_2.17/lib/x86_64-linux-gnu/ /tmp/libc6_2.17/lib/x86_64-linux-gnu/ld-2.17.so bin/python local/lib/python2.7/site-packages/tensorflow/models/image/mnist/convolutional.py
     

    And to exit:

    $ deactivate
     

    That works for me.

     
      September 16, 2020 12:48 PM IST
    0
  • That error mainly arises if your GNU C-Library is not up-to-date. You can check what version you're running using a simple

    $ ldd --version
    

     

    The output should be like this:

    ldd (Ubuntu EGLIBC 2.19-0ubuntu6.6) 2.19
    Copyright (C) 2014 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.
    There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Written by Roland McGrath and Ulrich Drepper.

     

    The 2.19 is your GLIBC version. To upgrade you can visit the GNU-C Library project website and download the latest version. The link to the latest glibc is here : GNU-C library Download At the time of writing this answer the latest stable version was 2.22.

    I tried running tensorflow on both Ubuntu 12.04 and 14.04. Ubuntu 14.04 doesn't throw this issue as it comes with glibc 2.19 installed by default.

    Hope it helps.

      October 19, 2021 2:44 PM IST
    0
  • I tried @shivakumar kota's solution and still had an annoying:

    ImportError: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found

    I am on CentOS 6.7, it also lacks an updated c++ standard lib, so to build on BR_User solution I extracted the correct libstdc++ package, however I found no need for the virtual environment.

    Supposing you have already installed tensorflow, it gives:

    mkdir ~/my_libc_env
    cd ~/my_libc_env
    wget http://launchpadlibrarian.net/137699828/libc6_2.17-0ubuntu5_amd64.deb
    wget http://launchpadlibrarian.net/137699829/libc6-dev_2.17-0ubuntu5_amd64.deb
    wget ftp.riken.jp/Linux/scientific/7.0/x86_64/os/Packages/libstdc++-4.8.2-16.el7.x86_64.rpm
    ar p libc6_2.17-0ubuntu5_amd64.deb data.tar.gz | tar zx
    ar p libc6-dev_2.17-0ubuntu5_amd64.deb data.tar.gz | tar zx
    rpm2cpio libstdc++-4.8.2-7mgc30.x86_64.rpm| cpio -idmv

    and then run python with:

    LD_LIBRARY_PATH="$HOME/my_libc_env/lib/x86_64-linux-gnu/:$HOME/my_libc_env/usr/lib64/" $HOME/my_libc_env/lib/x86_64-linux-gnu/ld-2.17.so `which python`

     

    This post was edited by Viaan Prakash at September 16, 2020 1:00 PM IST
      September 3, 2020 5:55 PM IST
    0