无法加载本机TensorFlow运行时:导入TensorFlow时出错

Pal*_*uri 5 python tensorflow

我在Ubuntu 17.04 32bit上从源代码构建TensorFlow

导入张量流时收到此消息

palash @ ash:〜$ python

Python 3.6.0 |Anaconda 4.3.1 (32-bit)| (default, Dec 23 2016, 12:22:10) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "/home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 61, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
  File "/home/palash/anaconda3/lib/python3.6/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/home/palash/anaconda3/lib/python3.6/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: /home/palash/anaconda3/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow.so)
Run Code Online (Sandbox Code Playgroud)

在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 72, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 61, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
  File "/home/palash/anaconda3/lib/python3.6/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/home/palash/anaconda3/lib/python3.6/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: /home/palash/anaconda3/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow.so)
Run Code Online (Sandbox Code Playgroud)

无法加载本地TensorFlow运行时。

参见https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error

出于某些常见原因和解决方案。寻求帮助时,在此错误消息上方包括整个堆栈跟踪。

my bazel info:
palash@ash:~$ bazel version
Build label: 0.4.5- (@non-git)
Build target: bazel-out/local-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri May 19 01:31:26 2017 (1495157486)
Build timestamp: 1495157486
Build timestamp as int: 1495157486

my TensorFlow version : 1.0.1
Run Code Online (Sandbox Code Playgroud)

abb*_*han 3

我找到了某种意义上的解决方案,也许这似乎是tensorflow版本1.6或更高版本中的一些兼容性错误。

将tensorflow降级到版本1.5解决了我的问题。

为此,我建议使用卸载 TensorFlow 1.8 版,pip uninstall tensorflow然后使用 再次安装 1.5 版pip install tensorflow==1.5

此外,我建议卸载并重新安装 keras 库。