【问题标题】:tensorflow.python.pywrap_tensorflow_internal no module windows 10 tensorflow gputensorflow.python.pywrap_tensorflow_internal 无模块 windows 10 tensorflow gpu
【发布时间】:2019-03-16 18:29:21
【问题描述】:

“tensorflow-cpu”在我的 Windows 10 设备上运行良好。 我试图安装 tensorflow-gpu,安装后无法导入,显示以下错误。

tensorflow.python.pywrap_tensorflow_internal 无模块

我已经安装了以下

CUDA 10.1

Nvidia 显卡驱动程序版本 419

CUDA 10.1 的 CUDnn

VC++ 2015 REDIST

谁能说我在这里缺少的是完整的错误消息。

Traceback (most recent call last):
  File "D:\Program Files\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "D:\Program Files\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "D:\Program Files\Python\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 "D:\Program Files\Python\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "D:\Program Files\Python\lib\imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Program Files\Python\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "D:\Program Files\Python\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "D:\Program Files\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "D:\Program Files\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "D:\Program Files\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "D:\Program Files\Python\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 "D:\Program Files\Python\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "D:\Program Files\Python\lib\imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: The specified module could not be found.

【问题讨论】:

    标签: python windows tensorflow


    【解决方案1】:

    如果您确定您的 Windows 机器上安装了 Visual C++ 2015 Redist,那么可能是 CUDA 版本和 Tensorflow 之间的版本冲突强>版本。因为较新的版本有一些冲突,而且 tensorflow 需要精确版本的 CUDA 和 CUDnn 库才能正常工作。

    正确配置它的最佳方法是使用 Anaconda 来安装和配置 tensorflow-gpu,因为 conda 会自动为相应的 tensorflow 下载所有必要版本的 CUDA 和 CUDnn

    问题是新的 Anaconda 默认使用 Python 3.7.x,tensorflow 或 tensorflow-gpu 不支持

    所以安装Anaconda就可以下载了here

    现在使用 conda 和 python 3.6.x 创建一个虚拟环境,通过在 Anaconda Prompt 中键入以下内容来配置

    conda create -n yourenvname python=3.6 anaconda
    

    现在通过输入切换到您的环境

    conda activate yourenvname
    

    现在检查 python 版本,使用 which 应该会显示类似这样的内容

    > python --version
    Python 3.6.7 :: Anaconda custom (64-bit)
    

    现在终于安装 tensorflow-gpu

    conda install tensorflow-gpu
    

    现在打开 python 并尝试导入 tensorflow

    >>> import tensorflow as tf
    >>> sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
    

    恭喜!一切就绪。

    【讨论】:

      猜你喜欢
      • 2021-08-29
      • 2017-09-20
      • 2018-04-10
      • 2018-09-11
      • 2017-09-29
      • 1970-01-01
      • 1970-01-01
      • 2017-09-29
      • 1970-01-01
      相关资源
      最近更新 更多