Dll加载失败



我的代码是这样的,这是一个来自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:Python38libsite-packagestensorflowpythonpywrap_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:Python38libsite-packagestensorflow__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:Python38libsite-packagestensorflowpython__init__.py", line 39, in <module>
from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
File "C:Python38libsite-packagestensorflowpythonpywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:Python38libsite-packagestensorflowpythonpywrap_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,同样的错误发生了,我似乎找不到解决方案,所以请帮助我

乐观的快速检查,确保您安装了最新的Visual c++ DLL

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

你可以自己编译TF或者使用别人的构建来运行没有AVX(参见:运行TensorFlow 2.0在CPU上没有AVX)。在我的情况下,我能够使用这个Stack Overflow答案中引用的非官方TF python构建从这里安装TF 2.4 https://github.com/fo40225/tensorflow-windows-wheel。

Intel Ark i7-4790 AVX示例图像

相关内容

  • 没有找到相关文章