简体   繁体   中英

What causes Tensorflow Import Error: DLL load failed?

I am using Anaconda environment on Windows 10. I have installed tensorflow-gpu using pip and when I try to import tensorflow, I get this import error below. I have tried to use cpu version of tensorflow and to reinstall all packages with new conda environment. My python is version 3.7 and tensorflow-gpu version 2.1.0.

    >>> import tensorflow as tf
Traceback (most recent call last):
  File "C:\Users\ossik\anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\ossik\anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\ossik\anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "C:\Users\ossik\anaconda3\envs\tensorflow-gpu\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\ossik\anaconda3\envs\tensorflow-gpu\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: Määritettyä osaa ei löydy.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\ossik\anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\__init__.py", line 101, in <module>
    from tensorflow_core import *
  File "C:\Users\ossik\anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "C:\Users\ossik\anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
    module = self._load()
  File "C:\Users\ossik\anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\__init__.py", line 44, in _load
    module = _importlib.import_module(self.__name__)
  File "C:\Users\ossik\anaconda3\envs\tensorflow-gpu\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\ossik\anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow_core\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\ossik\anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\ossik\anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\ossik\anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\ossik\anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "C:\Users\ossik\anaconda3\envs\tensorflow-gpu\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\ossik\anaconda3\envs\tensorflow-gpu\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: Määritettyä osaa ei löydy.


Failed to load the native TensorFlow runtime.

Do you have any idea what causes this error?

  • Try to downgrade and install tensorflow.

pip install tensorflow==2.0

  • if you use gpu

pip install --upgrade tensorflow-gpu==2.0

  • or try downloading these visual studio files click here

This could be because you have a CPU(probably old), which can not support AVX instructions (for example, Intel Pentium or similar). You could solve this problem using this approach:

pip3 uninstall tensorflow

Go here: link with tensorflow 2.1.0 wheels which has been precompiled with SSE2 instructions .

Download wheel to your project, then install tensorflow using pip install <filename.wheel> . And try again - error should be solved

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM