windows - 安装 Tensorflow 的问题——不是 CUDA/CuDNN 问题

标签 windows tensorflow import installation python-3.6

我最近开始接触 Tensorflow,但我遇到了安装问题。每次我尝试导入它时,我都会收到以下错误

>>> import tensorflow as tf
Traceback (most recent call last):
  File "C:\Users\[user]\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\[user]\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 571, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
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 "C:\Users\[user]\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\[user]\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\[user]\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 16, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\Users\[user]\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\[user]\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "C:\Users\[user]\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\[user]\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\[user]\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\[user]\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 571, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
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 "C:\Users\[user]\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\[user]\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\[user]\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 16, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\Users\[user]\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'


Failed to load the native TensorFlow runtime.

我查看了与我有同样问题的其他堆栈溢出帖子,他们建议从 NVIDIA 获取 CUDA 库。问题是,我既没有 NVIDIA 显卡也没有 GPU 版本的 tensorflow,所以我认为这不是问题所在。还有一些建议确保安装了 Microsoft visual studio 可再发行组件,它们确实安装了。

如果这是一个基于系统变量的问题,我将不胜感激帮助更改系统变量,因为我是新手。谢谢!

一些系统信息:

  • 操作系统:Microsoft Windows 10 专业版 10.0.17134
  • 中央处理器:英特尔至强 E5620
  • 显卡:Radeon RX 480
  • Python 版本:3.6.5 amd64 Tensorflow
  • 安装方式:pip install tensorflow

最佳答案

@user1735003 弄明白了。 我卸载了最新版本的tensorflow

pip uninstall tensorflow

然后安装tensorflow 1.5

pip install tensorflow==1.5

然后我验证了安装是否适用于脚本

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

我得到了正确的输出

Hello, TensorFlow!

关于windows - 安装 Tensorflow 的问题——不是 CUDA/CuDNN 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50430086/

相关文章:

c++ - 在Windows上进行_CONTEXT结构调试:如何?

python - 在Embedding Layer之后应用Dropout Layer和通过LSTM dropout参数应用dropout效果一样吗?

命令提示符中的 python 模块导入问题

python - 使用更改的模块路径对 python 对象进行 unpickling

c++ - 导入 .so 时导入语句的顺序是否重要?

python - 使用Python C API时如何中断Windows上的Python子进程?

windows - 使用 COPY 命令合并文件并获取奇数字符

Windows Server 2016 Docker 镜像支持 SQL Server?

python - 如何在 keras/tensorflow 中定义秩大于 4 的张量上的 2D 卷积

python - Keras : AttributeError: 'int' object has no attribute 'ndim' when using model. 适合