简体   繁体   English

无法加载本机 TensorFlow 运行时。 蟒蛇 3.5.2

[英]Failed to load the native TensorFlow runtime. Python 3.5.2

I'm trying to install Tensorflow in my PC, i installed Python 3.5.2 64-bit, cuda_8.0.61 for windows 10 and cudnn-8.0-windows10-x64-v6.0我正在尝试在我的 PC 中安装 Tensorflow,我安装了 Python 3.5.2 64 位、cuda_8.0.61 for windows 10 和 cudnn-8.0-windows10-x64-v6.0

I used "native" pip to install GPU version of Tensorflow, then i open IDLE and testing with "import tensorflow as tf" and i got the error bellow我使用“本机”pip 来安装 GPU 版本的 Tensorflow,然后我打开 IDLE 并使用“import tensorflow as tf”进行测试,我得到了下面的错误

How can i fix this ?我怎样才能解决这个问题 ? Thanks you in advance <3提前致谢 <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.

I managed to run Tensorflow on Windows following these steps.按照这些步骤,我设法在 Windows 上运行了 Tensorflow。 Hope it helps!希望能帮助到你! It may change depending in which folder you installed Python.它可能会根据您安装 Python 的文件夹而改变。

  1. Download and install Python 3.5.x下载并安装 Python 3.5.x
  2. Download and install Nvidia CUDA Toolkit下载并安装 Nvidia CUDA 工具包
  3. Download CuDNN 5.1下载 CuDNN 5.1
  4. Copy CuDNN files to Nvidia CUDA toolkit folder when 2. has completed (usually is located on C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0) 2. 完成后将CuDNN文件复制到Nvidia CUDA toolkit文件夹(通常位于C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0)

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

    5.1 TensorFlow dependencies 5.1 TensorFlow 依赖

    • make sure that Visual C++ Redistributate 2015 x64 is installed.确保安装了 Visual C++ Redistributate 2015 x64。 If not, download it如果没有,请下载
    • move _curses_curses.cp35-win_amd64.pyd and _curses_panel.cp35-win_amd64.pyd to C:\\Users\\Username\\AppData\\Local\\Programs\\Python\\Python35\\Lib\\site-packages (or you may need to download them as the next packages. just Ctrl+f for 'curses')将 _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 表示“诅咒”)
    • download and install these packages via pip (move to the directory where they were downloaded, open a command prompt and make 'pip install package_name')通过 pip 下载并安装这些包(移动到下载它们的目录,打开命令提示符并输入“pip install package_name”)
    • open command prompt and make 'pip install matplotlib'打开命令提示符并制作“pip install matplotlib”

Why don't try Anaconda?为什么不试试 Anaconda?

conda create -n gpu_env tensorflow-gpu
conda activate gpu_env

As easy as that.就这么简单。 All the packages and runtime needed (Visual Studio included) will be brought together while you watch in awe :).当您敬畏地观看时,所需的所有包和运行时(包括 Visual Studio)将汇集在一起​​:)。 Give it a try!试一试!

Caveat: You need to run Keras from inside tensorflow in order for it to detect and use your GPU .警告:您需要从 tensorflow 内部运行 Keras ,以便它检测和使用您的 GPU Otherwise if you use just keras and tensorflow as a backend, Keras will use plain tensorflow and not tensorflow-gpu .否则,如果您只使用 keras 和 tensorflow 作为后端, Keras 将使用普通的 tensorflow 而不是 tensorflow-gpu Boths are installed side by side.两者并排安装。

Meaning you should code it this way:这意味着你应该这样编码:

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
.............
.............

Hope this help.希望这有帮助。

Try:尝试:

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

to install tensorflow instead of:安装 tensorflow 而不是:

pip install --upgrade tensorflow-gpu

My computer is Windows with CPU and I have had same issues.我的电脑是带 CPU 的 Windows,我也遇到了同样的问题。 I uninstall tensorflow 1.9 and install 1.5 instead.我卸载了 tensorflow 1.9 并安装了 1.5。 It works right now.它现在工作。

If the problem persists check the version numbering and make sure cuda and TF are compatible.如果问题仍然存在,请检查版本编号并确保 cuda 和 TF 兼容。

Check the version numbering here在此处检查版本编号

or for a simpler way, use Anaconda或者更简单的方法,使用 Anaconda

conda create --name new_env_name tensorflow-gpu
activate new_env_name

I successfully installed TensorFlow GPU version 1.12 (latest until the date of writing) with Cuda 9.0, GeForce 1050 Ti, Windows 10 and Python 3.6.7我在 Cuda 9.0、GeForce 1050 Ti、Windows 10 和 Python 3.6.7 上成功安装了 TensorFlow GPU 版本 1.12(直到撰写本文为止的最新版本)

Note: You have installed the CUDA Toolkit (version 9) for TensorFlow to recognize your GPU注意:您已经为 TensorFlow 安装了 CUDA Toolkit(版本 9)来识别您的 GPU

我的问题是一个名为 protobuf 的包,它是通过使用pip install https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.0rc0-cp35-cp35m-win_amd64.whl解决的,它升级了 protobuf到 3.6.1 并解决了错误。

Everything could be installed from the console:一切都可以从控制台安装:

conda create --name tf-gpu
conda install -c aaronzs tensorflow-gpu
conda install -c anaconda cudatoolkit
conda install -c anaconda cudnn
conda install keras-gpu

I have the same problem with you.我和你有同样的问题。 The problem is that Anaconda automatically updates the python version when installing ipython and spyder, which becomes version 3.6.问题是Anaconda在安装ipython和spyder时自动更新python版本,变成3.6版本。 You can change the python version to version 3.5 by entering the tensorflow environment via Anaconda.通过Anaconda进入tensorflow环境可以将python版本改为3.5版本。 enter image description here在此处输入图片说明

暂无
暂无

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

相关问题 无法加载本地TensorFlow运行时。 Windows 10上的Python 3.6 - Failed to load the native TensorFlow runtime. Python 3.6 on Windows 10 “无法加载本机 TensorFlow 运行时。” - “Failed to load native TensorFlow runtime.” 无法加载本机 TensorFlow 运行时。? - Failed to load the native TensorFlow runtime.? Tensorflow:导入失败,并显示“无法加载本机TensorFlow运行时。” - Tensorflow: Import failed with “Failed to load the native TensorFlow runtime.” 无法加载本机 TensorFlow 运行时。 (Colab 错误) - Failed to load the native TensorFlow runtime. (Colab error) 无法加载本机 TensorFlow 运行时。 下载anaconda 3-5.2 - Failed to load the native TensorFlow runtime. Downloaded anaconda 3-5.2 “无法加载本机 TensorFlow 运行时。” 使用 rocm 导入 tensorflow 时出错 - “Failed to load the native TensorFlow runtime.” error when importing tensorflow with rocm 无法加载本机TensorFlow运行时。 原因:未找到图像。 我究竟做错了什么? - Failed to load the native TensorFlow runtime. Reason : Image not found. What am I doing wrong? 无法加载本地TensorFlow运行时。 运行g2p-seq2seq --version时 - Failed to load the native TensorFlow runtime. when running g2p-seq2seq --version 如何修复“无法加载本机 TensorFlow 运行时”。 尝试在 gpu 上运行时出错? - How to fix "Failed to load the native TensorFlow runtime." error when attempting running on gpu?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM