簡體   English   中英

無法加載本機TensorFlow運行時:導入tensorflow時出錯

[英]Failed to load the native TensorFlow runtime : error while importing tensorflow

我在Ubuntu 17.04 32bit上從源代碼構建了TensorFlow

我在導入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)

在處理上述異常期間,發生了另一個異常:

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)

無法加載本機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

我發現這個解決方案可能似乎是tensorflow 1.6或更高版本中的一些兼容性錯誤。

將張量流降級到1.5版解決了我的問題。

為此,我建議使用pip uninstall tensorflow卸載tensorflow版本1.8,然后使用pip install tensorflow==1.5再次安裝版本pip install tensorflow==1.5

另外我建議卸載並重新安裝keras庫。

這可能是因為兼容性問題。 對於我的Ubuntu 18服務器,我不得不使用tensorflow == 1.12,它現在可以工作了。

嘗試降級最新版本(1.12,現在是2019年3月26日)並查看哪個版本有效。

此腳本嘗試一個版本(trytfver.sh):

pip uninstall tensorflow -y
pip install --user tensorflow==$1
python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"

嘗試如下:

bash trytfver.sh 1.12
bash trytfver.sh 1.11
bash trytfver.sh 1.10
bash trytfver.sh 1.9
bash trytfver.sh 1.8
bash trytfver.sh ...

並查看是否出現任何“未定義的符號”錯誤,例如,我在1.11上有錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM