【问题标题】:"Failed to load native TensorFlow runtime."“无法加载原生 TensorFlow 运行时。”
【发布时间】:2019-11-13 03:27:02
【问题描述】:

所以我创建了一个程序来从 TensorFlow 加载数据集,但我遇到了一个错误,我不知道它是什么意思。

我的代码是:

import tensorflow as tf 
from tensorflow import keras
import numpy as np
import matplotlib.pyplot as plt 

data = keras.dataset_fashion_mnist

(train_images, train_labels), (test_images, test_labels) = data.data_load()

print(train_labels[1])

我应该得到一个数字作为输出而不是错误。

错误是:

Traceback (most recent call last):
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "helloworld.py", line 1, in <module>
    import tensorflow as tf
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\__init__.py", line 98, in <module>
    from tensorflow_core import *
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
    module = self._load()
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\__init__.py", line 44, in _load
    module = _importlib.import_module(self.__name__)
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

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

我不知道该怎么做才能解决这个问题以及尝试什么。我确保我已经安装了 tensorflow 并且我已经安装了。 我认为这与图书馆 iteff 有关系。

【问题讨论】:

    标签: python python-3.x tensorflow


    【解决方案1】:

    您的错误似乎与此类似:https://github.com/tensorflow/tensorflow/issues/22794

    一般的解决方案是使用特定版本的 CUDA 和特定版本的 tensorflow,例如

    tensorflow-gpu==1.14.0
    python 3.6.8
    CUDA v10.0
    cudnn 7.4.1.5
    

    您能提供您的库版本吗?我建议使用 conda 在 Windows 上安装 tensorflow,因为它有助于安装正确的版本,而不是自己设置。

    编辑

    请尝试这些步骤(摘自 Tensorflow 的文档:https://www.tensorflow.org/install/pip)

    1. 转到 Visual Studio 下载:https://visualstudio.microsoft.com/vs/older-downloads/

    2. 选择可再发行组件和构建工具

    3. 下载并安装 Microsoft Visual C++ 2015 Redistributable 更新 3

    在 Windows 上启用长路径:https://superuser.com/questions/1119883/windows-10-enable-ntfs-long-paths-policy-option-missing

    最后,请确保您的 CPU 支持 AVX 指令:https://en.wikipedia.org/wiki/Advanced_Vector_Extensions#CPUs_with_AVX

    【讨论】:

    • 我使用的是 tensorflow 2.0.0
    • 另外,我无法安装 CUDA,因为我收到此错误:``` 错误:找不到满足要求的版本 CUDA==10.0(来自版本:无)错误:没有匹配发现 CUDA==10.0 ``` 的分布
    • 您的 GPU 支持 CUDA 吗?你是如何安装 CUDA 的?您是否遵循本指南:docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows 或其他内容?
    • 我有一个英特尔 GPU,所以我认为它不支持它。
    • 如果是这样,可以肯定的是,您使用的是tensorflow,而不是tensorflow-gpu,对吗?我不认为tensorflow-gpu 可以与英特尔 GPU 一起使用。我已经更新了答案,增加了安装 MSVC 并在 Windows 上启用长路径的步骤,你可以试试吗?如果还是不行,能否提供一下你的 CPU 型号?
    猜你喜欢
    • 1970-01-01
    • 2020-04-28
    • 2018-12-05
    • 2020-07-15
    • 2017-11-21
    • 2017-10-12
    • 2018-03-20
    • 1970-01-01
    • 2019-06-27
    相关资源
    最近更新 更多