Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
355 views
in Technique[技术] by (71.8m points)

tensorflow - Dll load failed

My code is this, this is a test code from a 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()

And this is what happens when I run it:

Traceback (most recent call last):
  File "C:Python38libsite-packagesensorflowpythonpywrap_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-packagesensorflow\__init__.py", line 41, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "C:Python38libsite-packagesensorflowpython\__init__.py", line 39, in <module>
    from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
  File "C:Python38libsite-packagesensorflowpythonpywrap_tensorflow.py", line 83, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:Python38libsite-packagesensorflowpythonpywrap_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.

I installed tensorflow from both anaconda and pip and same error happens, I cant seem to find a solution on this one so please help me out

question from:https://stackoverflow.com/questions/65932550/dll-load-failed

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The optimistic quick check, make sure you have the latest Visual C++ DLL installed.

I just encountered this myself; in my case the system I was trying to run Tensorflow on uses a G3220. According to Issue #39007 TensorFlow requires AVX extensions, which my CPU does not support. You can do a quick check to see if your processor supports AVX extensions by searching for it on the Intel Ark (Link to my G3220 which does not support AVX and a link to a i7-4790 that does support AVX. I suspect this is the same problem that you are having.

You may be able to compile TF yourself or use a build someone else made to run without AVX (see: Run TensorFlow 2.0 on CPU without AVX). In my case, I was able to use the unofficial TF python build referenced in this Stack Overflow answer to install TF 2.4 from here https://github.com/fo40225/tensorflow-windows-wheel.

Intel Ark i7-4790 AVX Example Image


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...