Sophia S.
Sophia S.

Reputation: 331

Tensorflow (1.13.1) Exception when import: DLL load failed (Windows 10)

I have installed Python 3.7.3 on my Windows 10 machine. Afterwards I downloaded with the tensorflow module: pip install https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.13.1-cp37-cp37m-win_amd64.whl

On the computer is Visual Studio 2019 installed with additional MSVC v141 (VS 2017) and MSVC v140 (VS 2015).

When I run import tensorflow as tf in python, I get the following error:

Traceback (most recent call last):
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: Eine DLL-Initialisierungsroutine ist fehlgeschlagen.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: Eine DLL-Initialisierungsroutine ist fehlgeschlagen.


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 have tested some solutions from other answers, but nothing has solved my problem. Does anyone have an idea?


Edit: The reason was that my CPU has no AVX support. Now it works.

Upvotes: 4

Views: 1367

Answers (1)

mlneural03
mlneural03

Reputation: 853

TensorFlow release binaries version 1.6 and higher are prebuilt with AVX instruction sets.

Therefore on any CPU that does not have these instruction sets, either CPU or GPU version of TF will fail to load.
Apparently, your CPU model does not support AVX instruction sets. You can still use TensorFlow with the alternatives given below:

  • Try Google Colab to use TensorFlow.
    The easiest way to use TF will be to switch to google colab.You get pre-installed latest stable TF version. Also you can use pip install to install any other preferred TF version.
    It has an added advantage since you can you easily switch to different hardware accelerators (cpu, gpu, tpu) as per the task. All you need is a good internet connection and you are all set.
  • Try to build TF from sources by changing CPU optimization flags.

Upvotes: 1

Related Questions