无法加载本机TensorFlow运行时-DLL加载失败

时间:2020-09-21 17:01:38

标签: python python-3.x tensorflow anaconda spyder

不知道该如何处理:

  • DLL加载失败:无法正常安装模块(瑞典语:找不到所需的模块)
  • 无法加载本机TensorFlow运行时。

目前我无法使用tensorflow做任何事情。

(spyder-env2) PS C:\> python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

TRACEBACK:

Traceback (most recent call last):
  File "C:\Users\eid\AppData\Local\Continuum\anaconda2\envs\tensorflow36\envs\spyder-env2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
    from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed: Det går inte att hitta den angivna modulen.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\eid\AppData\Local\Continuum\anaconda2\envs\tensorflow36\envs\spyder-env2\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "C:\Users\eid\AppData\Local\Continuum\anaconda2\envs\tensorflow36\envs\spyder-
env2\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
    from tensorflow.python.eager import context
  File "C:\Users\eid\AppData\Local\Continuum\anaconda2\envs\tensorflow36\envs\spyder-env2\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
    from tensorflow.python import pywrap_tfe
  File "C:\Users\eid\AppData\Local\Continuum\anaconda2\envs\tensorflow36\envs\spyder-env2\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\eid\AppData\Local\Continuum\anaconda2\envs\tensorflow36\envs\spyder-env2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\eid\AppData\Local\Continuum\anaconda2\envs\tensorflow36\envs\spyder-env2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
    from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed: Det går inte att hitta den angivna modulen.


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.

1 个答案:

答案 0 :(得分:0)

这个问题可能是因为 Tensorflow 需要 MSVC 2019 可再发行版,或者您的 CPU 不支持 AVX2 指令,或者您的 CPU/Python 是 32 位。

有一种解决方法,要么您必须从源代码构建 Tensorflow,要么使用 google colaboratory 来工作。 使用 here 中提到的说明从源代码编译。