如何修复无法在 Conda 上加载本机 Tensorflow 运行时

Posted

技术标签:

【中文标题】如何修复无法在 Conda 上加载本机 Tensorflow 运行时【英文标题】:How to fix Failed to load the native Tensorflow runtime on Conda 【发布时间】:2021-10-19 00:57:27 【问题描述】:

我使用此链接 here 安装了所有软件包和 conda 本身(我遵循的所有安装说明都在链接中)

Visual Code 已按照说明与 Java SE Dev Kit 11 一起安装,并且所有依赖项都已正确安装。但是,在检查上面链接中的 GUI 分支并运行 python deepometry_GUI.py 时,我收到关于 1 或 2 个缺少 DLL 的错误。提醒一下,这一切都在 Conda 环境中

Traceback (most recent call last):
  File "C:\Users\Rafay Osmani\.conda\envs\Deepometry\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\Rafay Osmani\.conda\envs\Deepometry\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\Rafay Osmani\.conda\envs\Deepometry\lib\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 "C:\Users\Rafay Osmani\.conda\envs\Deepometry\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\Rafay Osmani\.conda\envs\Deepometry\lib\imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "Deepometry_GUI.py", line 20, in <module>
    import tensorflow
  File "C:\Users\Rafay Osmani\.conda\envs\Deepometry\lib\site-packages\tensorflow\__init__.py", line 22, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "C:\Users\Rafay Osmani\.conda\envs\Deepometry\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\Rafay Osmani\.conda\envs\Deepometry\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\Rafay Osmani\.conda\envs\Deepometry\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\Rafay Osmani\.conda\envs\Deepometry\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\Rafay Osmani\.conda\envs\Deepometry\lib\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 "C:\Users\Rafay Osmani\.conda\envs\Deepometry\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\Rafay Osmani\.conda\envs\Deepometry\lib\imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: The specified module could not be 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.

看来我需要做的就是安装丢失的 DLL,我正在路上。问题是错误信息不明确 而且我不知道我需要安装什么 DLL。如果能告诉我如何解决这个问题,我们将不胜感激。

【问题讨论】:

【参考方案1】:

通过执行以下命令获取您的 conda 环境的路径。

import os
os.environ['PATH']

然后将获得的路径添加到你的系统路径下,这样就可以了。

【讨论】:

以上是关于如何修复无法在 Conda 上加载本机 Tensorflow 运行时的主要内容,如果未能解决你的问题,请参考以下文章

如何修复我的自定义 conda 包的 conda UnsatisfiableError?

如何更新 cupy/CUDA 以使其再次工作并修复我的 conda 环境?

在 conda 中创建环境时如何修复错误

如何使用 Remote-SSH 修复 VS Code 错误:“终端进程无法启动:启动期间发生本机异常(forkpty(3)失败。)。”?

如何在 conda 环境中安装库时修复未找到入口点

如何在sketch_rnn算法中修复'allow_pickle = False时无法加载对象数组'