无法加载本地TensorFlow运行时。 Python 3.5.2
python
python-3.x
tensorflow
5
0

我正在尝试在PC上安装Tensorflow,我安装了适用于Windows 10的Python 3.5.2 64位,cuda_8.0.61和cudnn-8.0-windows10-x64-v6.0

我使用“本地” pip安装了Tensorflow的GPU版本,然后打开了IDLE,并使用“将tensorflow导入为tf”进行了测试,但出现了以下错误

我怎样才能解决这个问题 ?预先感谢您<3

Traceback (most recent call last):
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 577, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 906, in create_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
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 "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import tensorflow as tf
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\__init__.py", line 51, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 52, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 577, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 906, in create_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
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 "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
参考资料:
Stack Overflow
收藏
评论
共 4 个回答
高赞 时间 活跃

为什么不尝试Anaconda?

conda create -n gpu_env tensorflow-gpu
conda activate gpu_env

就这么简单。当您敬畏观看时,所有需要的软件包和运行时(包括Visual Studio)将被放在一起。 试试看!

警告:您需要从tensorflow内部运行Keras ,以使其检测和使用GPU 。否则,如果仅使用keras和tensorflow作为后端, 那么Keras将使用普通的tensorflow而不是tensorflow-gpu 。两者并排安装。

意思是您应该这样编码:

import tensorflow as tf
from tensorflow.keras.models       import Sequential, load_model
from tensorflow.keras.layers       import Dense,Dropout
from tensorflow.keras.callbacks    import ModelCheckpoint, EarlyStopping,CSVLogger
from tensorflow.keras.utils        import plot_model
.............
.............

希望能有所帮助。

收藏
评论

我的计算机是带有CPU的Windows,但遇到了同样的问题。我卸载tensorflow 1.9并安装1.5。现在就可以使用。

收藏
评论

尝试:

pip install https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.0rc0-cp35-cp35m-win_amd64.whl

安装tensorflow而不是:

pip install --upgrade tensorflow-gpu
收藏
评论

按照以下步骤,我设法在Windows上运行Tensorflow。希望能帮助到你!它可能会根据安装Python的文件夹而改变。

  1. 下载并安装Python 3.5.x
  2. 下载并安装Nvidia CUDA工具包
  3. 下载CuDNN 5.1
  4. 2.完成后将CuDNN文件复制到Nvidia CUDA工具包文件夹中(通常位于C:\ Program Files \ NVIDIA GPU Computing Toolkit \ CUDA \ v8.0中)

    • 将cudnn \ bin \ cudnn64_5.dll复制到C:\ Program Files \ NVIDIA GPU Computing Toolkit \ CUDA \ v8.0 \ bin \
    • 将cudnn \ include \ cudnn.h复制到C:\ Program Files \ NVIDIA GPU Computing Toolkit \ CUDA \ v8.0 \ include \
    • 将cudnn \ lib \ x64 \ cudnn.lib复制到C:\ Program Files \ NVIDIA GPU Computing Toolkit \ CUDA \ v8.0 \ lib \ x64 \
  5. 通过pip命令提示符'pip install --upgrade tensorflow-gpu'安装Tensorflow

    5.1 TensorFlow依赖性

    • 确保已安装Visual C ++ Redistributate 2015 x64。如果没有,请下载
    • 将_curses_curses.cp35-win_amd64.pyd和_curses_panel.cp35-win_amd64.pyd移至C:\ Users \ Username \ AppData \ Local \ Programs \ Python \ Python35 \ Lib \ site-packages(否则您可能需要下载它们作为下一个软件包。只需按Ctrl + f即可获得“诅咒”)
    • 通过pip下载并安装这些软件包(移至下载它们的目录,打开命令提示符,然后输入“ pip install package_name”)
    • 打开命令提示符并进行“ pip install matplotlib”
收藏
评论
新手导航
  • 社区规范
  • 提出问题
  • 进行投票
  • 个人资料
  • 优化问题
  • 回答问题

关于我们

常见问题

内容许可

联系我们

@2020 AskGo
京ICP备20001863号