【问题标题】:TensorFlow Import Failure: Image not foundTensorFlow 导入失败:找不到图像
【发布时间】:2019-11-21 22:21:03
【问题描述】:

我正在尝试在我的 Mac 上安装和使用 TensorFlow 和 Python 3.6。我已按照 TensorFlow 安装站点 https://www.tensorflow.org/install 上列出的所有步骤进行操作,但在完成该过程后,在尝试将 TensorFlow 导入我的 Python 环境时出现 Failed to load the native TensorFlow runtime 错误。


我的电脑运行的是 MacOS 和 Python 3.6.3。我在 Anaconda 虚拟环境中。我已经完全阅读了安装指南(信中)并尝试从源代码以及预建的轮子目录进行安装。

import tensorflow as tf
Traceback (most recent call last):
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/anaconda3/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/anaconda3/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: dlopen(/anaconda3/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 10): Library not loaded: @rpath/libcublas.8.0.dylib
  Referenced from: /anaconda3/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
  Reason: image not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 51, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/anaconda3/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/anaconda3/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: dlopen(/anaconda3/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 10): Library not loaded: @rpath/libcublas.8.0.dylib
  Referenced from: /anaconda3/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
  Reason: image not found


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

我认为 TensorFlow 应该正在导入(除非我做的很糟糕),但是会抛出这个错误。我怀疑错误是由于安装不正确或路径问题造成的,但我不知道从哪里开始纠正这个问题。然而,这可能是一个更深层次的问题,因此如果有人能阐明解决方案,我们将不胜感激。

谢谢!

【问题讨论】:

  • libcublas 是一个 cuBLAS 库,它是 CUDA 的一部分。你确定你安装(或者可能试图从源代码编译)tensorflow 而不是tensorflow-gpu? MacOS 上的tensorflow 不支持 GPU。

标签: python python-3.x macos tensorflow


【解决方案1】:

我认为在这里解决了类似的问题: Failed to load the native TensorFlow runtime in Mac OSX

来自用户mikkokotila的解决方案是使用

  1. 一个特定的 tensorflow 版本

    pip install tensorflow==1.5

  2. 使用 conda 安装

    conda 安装张量流

【讨论】:

    猜你喜欢
    • 2012-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-11
    • 2021-04-04
    • 2021-03-04
    相关资源
    最近更新 更多