简体   繁体   English

如何修复“无法加载本机 TensorFlow 运行时”。 尝试在 gpu 上运行时出错?

[英]How to fix "Failed to load the native TensorFlow runtime." error when attempting running on gpu?

I've been running my tensorflow programs on my CPU.我一直在我的 CPU 上运行我的 tensorflow 程序。 However, it's been getting slow, so I wanted to set up a gpu environment to run it on my 1070ti.然而,它变得越来越慢,所以我想设置一个gpu环境在我的1070ti上运行它。 However, when after downloading CUDA 9.0 and CUDNN 7.4, tensorflow-gpu has trouble running it.但是,在下载 CUDA 9.0 和 CUDNN 7.4 后,tensorflow-gpu 无法运行。

The error appears whenever I try importing tensorflow in python.每当我尝试在 python 中导入 tensorflow 时都会出现错误。 I have tensorflow installed in a virtualenv environment, and the script running is inside the folder.我在 virtualenv 环境中安装了 tensorflow,并且运行的脚本在文件夹内。

import tensorflow

I get the following output:我得到以下输出:

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

According to this thread , these packages don't work on Windows 10:根据这个线程,这些包在 Windows 10 上不起作用:

  • Tensorflow 1.12.0 TensorFlow 1.12.0
  • Cuda toolkit 10.0.130 Cuda 工具包 10.0.130
  • cudnn 7.4.1.5 cudnn 7.4.1.5

However, someone said that you can try to downgrade Tensorflow to version 1.10 using pip:但是,有人说可以尝试使用 pip 将 Tensorflow 降级到 1.10 版本:

pip install tensorflow-gpu==1.10.0

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM