【问题标题】:Dll load faileddll加载失败
【发布时间】:2021-01-28 07:16:20
【问题描述】:

我的代码是这样的,这是来自 youtuber 的测试代码:

import numpy as np
import cv2 as cv
from tensorflow.keras import datasets, layers, models
import mathplotlib.pyplot as plt
(training_images, training_labels), (testing_images,
                                     testing_labels) = datasets.cifar10.load_data()
training_images, testing_images = training_images/255, training_labels/255
class_names = ['Plane', 'Car']

for i in range(16):
    plt.subplot(4, 4, i+1)
    plt.xticks([])
    plt.yticks([])
    plt.imshow(training_images[i], cmap=plt.cm.binary)
    plt.xlabel(class_names[training_labels[i][0]])
plt.show()

这就是我运行它时发生的情况:

Traceback (most recent call last):
  File "C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
    from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: A dynamic link library (DLL) initialization routine failed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "image classification test.py", line 3, in <module>
    from tensorflow.keras import datasets, layers, models
  File "C:\Python38\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "C:\Python38\lib\site-packages\tensorflow\python\__init__.py", line 39, in <module>
    from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
  File "C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
    from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: 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.

我从 anaconda 和 pip 都安装了 tensorflow,但发生了同样的错误,我似乎找不到解决方案,所以请帮助我

【问题讨论】:

    标签: tensorflow tensorflow2.0 importerror tensorflow-datasets python-3.8


    【解决方案1】:

    乐观快速检查,确保您拥有最新的Visual C++ DLL installed

    我自己也遇到过这个;在我的情况下,我试图在其上运行 Tensorflow 的系统使用 G3220。根据Issue #39007 TensorFlow 需要 AVX 扩展,我的 CPU 不支持。您可以通过在Intel Ark 上搜索它来快速检查您的处理器是否支持 AVX 扩展(链接到不支持 AVX 的我的 G3220 和指向不支持 AVX 的 i7-4790 的链接。我怀疑这与您遇到的问题相同。

    您可以自己编译 TF 或使用其他人制作的构建以在没有 AVX 的情况下运行(请参阅:Run TensorFlow 2.0 on CPU without AVX)。就我而言,我能够使用Stack Overflow answer 中引用的非官方 TF python 构建从这里https://github.com/fo40225/tensorflow-windows-wheel 安装 TF 2.4。

    Intel Ark i7-4790 AVX Example Image

    【讨论】:

      猜你喜欢
      • 2020-02-28
      • 2012-12-21
      • 2012-12-29
      • 2020-09-01
      • 2019-07-10
      • 2015-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多