简体   繁体   English

Tensorflow 2.1.0 - DLL 加载失败 - windows cpu

[英]Tensorflow 2.1.0 - DLL load failed - windows cpu

Installation of TensorFlow 2.1.0 was successful, but TensorFlow import failed. TensorFlow 2.1.0 安装成功,但 TensorFlow 导入失败。

Open question:开放问题:

Is there a library that is in a different location/not installed on the system that cannot be loaded?是否有无法加载的库位于不同位置/未安装在系统上?

Procedure for reproduction:繁殖程序:

1) create environment 1)创造环境

conda create --name tensorflow21_env

2) activate environment 2)激活环境

conda activate tensorflow21_env

3) install 3)安装

  1. conda install python=3.7
  2. pip install tensorflow-cpu #install tensorflow=2.1.0;

4) test 4)测试

python -c "import tensorflow as tf"

Stacktrace:堆栈跟踪:

    Traceback (most recent call last):
  File "C:\Anaconda3\envs\tensorflow21_env\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Anaconda3\envs\tensorflow21_env\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Anaconda3\envs\tensorflow21_env\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:\Anaconda3\envs\tensorflow21_env\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Anaconda3\envs\tensorflow21_env\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Anaconda3\envs\tensorflow21_env\lib\site-packages\tensorflow\__init__.py", line 101, in <module>
    from tensorflow_core import *
  File "C:\Anaconda3\envs\tensorflow21_env\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "C:\Anaconda3\envs\tensorflow21_env\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
    module = self._load()
  File "C:\Anaconda3\envs\tensorflow21_env\lib\site-packages\tensorflow\__init__.py", line 44, in _load
    module = _importlib.import_module(self.__name__)
  File "C:\Anaconda3\envs\tensorflow21_env\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Anaconda3\envs\tensorflow21_env\lib\site-packages\tensorflow_core\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Anaconda3\envs\tensorflow21_env\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Anaconda3\envs\tensorflow21_env\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Anaconda3\envs\tensorflow21_env\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Anaconda3\envs\tensorflow21_env\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:\Anaconda3\envs\tensorflow21_env\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Anaconda3\envs\tensorflow21_env\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: 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.

Installation Output:安装输出:

Output: conda install python=3.7输出:conda install python=3.7

Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: C:\Anaconda3\envs\tensorflow21_env

  added / updated specs:
    - python=3.7


The following NEW packages will be INSTALLED:

  ca-certificates    pkgs/main/win-64::ca-certificates-2020.1.1-0
  certifi            pkgs/main/win-64::certifi-2019.11.28-py37_0
  openssl            pkgs/main/win-64::openssl-1.1.1d-he774522_4
  pip                pkgs/main/win-64::pip-20.0.2-py37_1
  python             pkgs/main/win-64::python-3.7.6-h60c2a47_2
  setuptools         pkgs/main/win-64::setuptools-45.2.0-py37_0
  sqlite             pkgs/main/win-64::sqlite-3.31.1-he774522_0
  vc                 pkgs/main/win-64::vc-14.1-h0510ff6_4
  vs2015_runtime     pkgs/main/win-64::vs2015_runtime-14.16.27012-hf0eaf9b_1
  wheel              pkgs/main/win-64::wheel-0.34.2-py37_0
  wincertstore       pkgs/main/win-64::wincertstore-0.2-py37_0


Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: done

The dependency walker confirms that all DLLs could be loaded ( download dependency walker ).依赖项walker 确认可以加载所有DLL(下载依赖项walker )。

dependency_trace依赖跟踪

Addon: path for dependency walker插件:依赖步行者的路径

C:\Anaconda3\envs\tensorflow21_env\Lib\site-packages\tensorflow_core\python\_pywrap_tensorflow_internal.pyd

Update:更新:

My processor supports neither AVX nor AVX2 and therefore the tensorflow pip package could not be installed or to be more precise the tensorflow package could not be imported.我的处理器既不支持 AVX 也不支持 AVX2,因此无法安装 tensorflow pip 包,或者更准确地说,无法导入 tensorflow 包。

Interim solution:临时解决方案:

The interim solution for legacy & low-end CPU without AVX support is to install SSE-prebuild-binaries for tensorflow.没有 AVX 支持的传统和低端 CPU 的临时解决方案是为 tensorflow 安装 SSE-prebuild-binaries。 Go to tensorflow-windows-wheel and follow instruction to install either tensorflow 2.0.0 or 2.1.0.转到tensorflow-windows-wheel并按照说明安装 tensorflow 2.0.0 或 2.1.0。

Try this method:试试这个方法:
Uninstall the TensorFlow package that you installed using pip and reinstall using conda install tensorflow this may work!卸载您使用 pip 安装的 TensorFlow 包,然后使用conda install tensorflow重新安装,这可能会起作用! Now you can import TensorFlow without problems.现在您可以毫无问题地导入 TensorFlow。 I hope this can help you.我希望这可以帮助你。

If you need more detailed steps.如果您需要更详细的步骤。 Here, you can do the following below.在这里,您可以执行以下操作。

  • Run the anaconda prompt as an administrator.以管理员身份运行 anaconda 提示符。 (right click-> run as administrator). (右键单击-> 以管理员身份运行)。

  • pip uninstall tensorflow

  • Close anaconda prompt.关闭 anaconda 提示。

  • Again run anaconda prompt as administrator.再次以管理员身份运行 anaconda prompt。

  • type:类型:
    conda install tensorflow
    It will ask for some y / n它会要求一些y / n
    Type y .输入y

Now after all done, change your python interpreter's environment to anaconda environment where you installed tensorflow.现在完成后,将 python 解释器的环境更改为安装 tensorflow 的 anaconda 环境。

  • Now try importing tensorflow.现在尝试导入 tensorflow。

I hope this helps.我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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