• 使用pip安装tensorflow 0.80,python 使用tensorflow 0.80遇到的问题及处理方法


    http://blog.csdn.net/levy_cui/article/details/51251095

    1.python 版本切换到2.7

    推荐使用pythonbrew,http://blog.csdn.net/nuccch/article/details/17595161

    2.pip安装相关包


    安装tensorflow
    pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl

    Python 2.7.3 (default, Apr 26 2016, 11:18:30) 
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import tensorflow as tf
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/python27/lib/python2.7/site-packages/tensorflow/__init__.py", line 23, in <module>
        from tensorflow.python import *
      File "/usr/local/python27/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 45, in <module>
        from tensorflow.python import pywrap_tensorflow
      File "/usr/local/python27/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
        _pywrap_tensorflow = swig_import_helper()
      File "/usr/local/python27/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
        _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
    ImportError: /lib64/libc.so.6: version `GLIBC_2.15' not found (required by /usr/local/python27/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so)


    tensorflow0.80版本编译的时候使用GLIBC_2.15,系统自带的是GLIBC_2.12,所以报错了。

    我使用的方法(直接升级glibc):

    yum install gcc

    wget http://ftp.gnu.org/pub/gnu/glibc/glibc-2.17.tar.xz
    xz -d glibc-2.17.tar.xz
    tar -xvf glibc-2.17.tar
    cd glibc-2.17
    mkdir build
    cd build
    ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin  
    make && make install
    需要等大概10分钟。

    输入strings /lib64/libc.so.6|grep GLIBC发现已经更新 
    GLIBC_2.2.5
    GLIBC_2.2.6
    GLIBC_2.3
    GLIBC_2.3.2
    GLIBC_2.3.3
    GLIBC_2.3.4
    GLIBC_2.4
    GLIBC_2.5
    GLIBC_2.6
    GLIBC_2.7
    GLIBC_2.8
    GLIBC_2.9
    GLIBC_2.10
    GLIBC_2.11
    GLIBC_2.12
    GLIBC_2.13
    GLIBC_2.14
    GLIBC_2.15
    GLIBC_2.16
    GLIBC_2.17

    GLIBC_PRIVATE

    Python 2.7.3 (default, Apr 26 2016, 11:18:30) 
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import tensorflow as tf
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/python27/lib/python2.7/site-packages/tensorflow/__init__.py", line 23, in <module>
        from tensorflow.python import *
      File "/usr/local/python27/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 45, in <module>
        from tensorflow.python import pywrap_tensorflow
      File "/usr/local/python27/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
        _pywrap_tensorflow = swig_import_helper()
      File "/usr/local/python27/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
        _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
    ImportError: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /usr/local/python27/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so)




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

    #strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
    GLIBCXX_3.4
    GLIBCXX_3.4.1
    GLIBCXX_3.4.2
    GLIBCXX_3.4.3
    GLIBCXX_3.4.4
    GLIBCXX_3.4.5
    GLIBCXX_3.4.6
    GLIBCXX_3.4.7
    GLIBCXX_3.4.8
    GLIBCXX_3.4.9
    GLIBCXX_3.4.10
    GLIBCXX_3.4.11
    GLIBCXX_3.4.12
    GLIBCXX_3.4.13
    GLIBCXX_FORCE_NEW
    GLIBCXX_DEBUG_MESSAGE_LENGTH

    没有GLIBCXX_3.4.14版本支持,继续安装(注意:libstdc++6_4.7.2-5_amd64.deb这是64位,libstdc++6_4.7.2-5_i386.deb这个是32位)

    下载新版本,地址:http://ftp.de.debian.org/debian/pool/main/g/gcc-4.7/libstdc++6_4.7.2-5_amd64.deb
    ar -x libstdc++6_4.7.2-5_amd64.deb&&tar xvf data.tar.gz  

    #cd /root/usr/lib/x86_64-linux-gnu (进入解压文件的目录中,我这里是下/root目录下解压的)
    #ll
    lrwxrwxrwx 1 root root     19 Apr 26 15:21 libstdc++.so.6 -> libstdc++.so.6.0.17
    -rw-r--r-- 1 root root 991600 Jan  7  2013 libstdc++.so.6.0.17

    # find / -name libstdc++.so.6
    /usr/lib64/libstdc++.so.6
    /root/usr/lib/x86_64-linux-gnu/libstdc++.so.6

    #mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.bak
    #cp libstdc++.so.6.0.17 /usr/lib64/
    #cd /usr/lib64/

    #chmod +x libstdc++.so.6.0.17
    #ll libstdc++.so.6.0.17
    -rwxr-xr-x 1 root root 991600 Apr 26 15:30 libstdc++.so.6.0.17
    #ln -s libstdc++.so.6.0.17 libstdc++.so.6

    #strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
    GLIBCXX_3.4
    GLIBCXX_3.4.1
    GLIBCXX_3.4.2
    GLIBCXX_3.4.3
    GLIBCXX_3.4.4
    GLIBCXX_3.4.5
    GLIBCXX_3.4.6
    GLIBCXX_3.4.7
    GLIBCXX_3.4.8
    GLIBCXX_3.4.9
    GLIBCXX_3.4.10
    GLIBCXX_3.4.11
    GLIBCXX_3.4.12
    GLIBCXX_3.4.13
    GLIBCXX_3.4.14
    GLIBCXX_3.4.15
    GLIBCXX_3.4.16
    GLIBCXX_3.4.17
    GLIBCXX_DEBUG_MESSAGE_LENGTH





    >>> import tensorflow as tf
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/python27/lib/python2.7/site-packages/tensorflow/__init__.py", line 23, in <module>
        from tensorflow.python import *
      File "/usr/local/python27/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 45, in <module>
        from tensorflow.python import pywrap_tensorflow
      File "/usr/local/python27/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
        _pywrap_tensorflow = swig_import_helper()
      File "/usr/local/python27/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
        _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
    ImportError: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.19' not found (required by /usr/local/python27/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so)



    从网上下载libstdc++.so.6.0.20 

    推荐下载:

    http://download.csdn.net/download/arackethis/8395651

    (http://ftp.de.debian.org/debian/pool/main/g/gcc-4.8/或者

    http://download.csdn.net/detail/pomelover/7524227)



    放到/usr/lib64/下
    #chmod +x libstdc++.so.6.0.20
    #rm libstdc++.so.6
    #ln -s libstdc++.so.6.0.20 libstdc++.so.6
    #strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX

    [root@pachong1 lib64]# strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
    GLIBCXX_3.4
    GLIBCXX_3.4.1
    GLIBCXX_3.4.2
    GLIBCXX_3.4.3
    GLIBCXX_3.4.4
    GLIBCXX_3.4.5
    GLIBCXX_3.4.6
    GLIBCXX_3.4.7
    GLIBCXX_3.4.8
    GLIBCXX_3.4.9
    GLIBCXX_3.4.10
    GLIBCXX_3.4.11
    GLIBCXX_3.4.12
    GLIBCXX_3.4.13
    GLIBCXX_3.4.14
    GLIBCXX_3.4.15
    GLIBCXX_3.4.16
    GLIBCXX_3.4.17
    GLIBCXX_3.4.18
    GLIBCXX_3.4.19
    GLIBCXX_3.4.20
    GLIBCXX_FORCE_NEW
    GLIBCXX_DEBUG_MESSAGE_LENGTH



    终于成功了。
    [root@pachong1 lib64]# python
    Python 2.7.3 (default, Apr 26 2016, 11:18:30) 
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import tensorflow as tf
    >>> matrix1 = tf.constant([[3., 3.]])
    >>> matrix2 = tf.constant([[2.],[2.]])
    >>> product = tf.matmul(matrix1, matrix2)
    >>> print product
    Tensor("MatMul:0", shape=(1, 1), dtype=float32)
    >>> sess = tf.Session()
    >>> result = sess.run(product)
    >>> print result
    [[ 12.]]
    >>> sess.close()
    >>> exit()

  • 相关阅读:
    Linux网络相关命令firewalld和netfilter、iptables 使用(6/22)
    Linux时间设置与iptables命令
    负载均衡集群ipvsadm命令及基本用法
    LVS原理详解以及部署
    linux比较两个文件的不同(6/21)
    如何使用sql函数平均值、总数、最小值、最大值
    python中数据类型转换
    使用 getopt 处理命令行长参数
    Mysql常用命令行大全
    C#控制台程序使用Log4net日志组件
  • 原文地址:https://www.cnblogs.com/DjangoBlog/p/6867973.html
Copyright © 2020-2023  润新知