dll加载失败

时间:2021-01-28 07:16:20

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

我的代码是这样的,这是一个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 并且发生了同样的错误,我似乎无法找到解决方案,所以请帮帮我

1 个答案:

答案 0 :(得分:0)

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

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

您可以自己编译 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

相关问题