繁体   English   中英

“无法加载本机 TensorFlow 运行时。”

[英]“Failed to load native TensorFlow runtime.”

因此,我创建了一个程序来从 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])

我应该得到一个数字 output 而不是错误。

错误是:

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 有关。

您的错误似乎与此类似: 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. Go 到 Visual Studio 下载: https://visualstudio.microsoft.com/vs/older-downloads/

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

  3. 下载并安装 Microsoft Visual C++ 2015 Redistributable Update 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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM