如何解决“ ImportError:DLL加载失败:找不到指定的过程。”导入tensorflow-gpu时?

时间:2019-04-13 13:28:06

标签: tensorflow import keras gpu

我无法在python 3.6.0上导入tensorflow-gpu == 1.13.1。

我已经做了什么:

  1. Nvidia的驱动程序(我具有GEFORCE 840M,cuda支持该功能并具有计算能力5.0)。

  2. 我安装了Visual Studio 2017 Professional(未在工作负载中选择任何规范)。

  3. 我安装了CUDA 10.1(Visual Studio集成存在问题,因此我在安装过程中将其禁用了。)

  4. 我将Cudnn 7.5.0粘贴到了cuda的文件夹中。

  5. 重新启动。

  6. Pip在python 3.6.0上安装了tensorflow-gpu == 1.13.1。

  7. 但是我根本无法导入tensorflow,它显示了以下错误。

>>> import tensorflow as tf
Traceback (most recent call last):
  File "C:\Users\BenBouali\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\BenBouali\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\BenBouali\AppData\Local\Programs\Python\Python36\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\BenBouali\AppData\Local\Programs\Python\Python36\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\BenBouali\AppData\Local\Programs\Python\Python36\lib\imp.py", line 342, 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\BenBouali\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\BenBouali\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\BenBouali\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\BenBouali\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\BenBouali\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\BenBouali\AppData\Local\Programs\Python\Python36\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\BenBouali\AppData\Local\Programs\Python\Python36\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\BenBouali\AppData\Local\Programs\Python\Python36\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: The specified module could not be found.


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
>>>

目标: 显然能够导入tensorflow并从tensorflow库中导入keras。

1 个答案:

答案 0 :(得分:0)

在我的情况下,这是使用tensorflow-gpu==1.13.1检测正确的CUDA Toolkit / cuDNN版本的问题。

在此上花费了2个小时之后,我安装了CUDA Toolkit 10.0,并在用户环境设置(Windows 10)中将TF_CUDA_VERSION环境变量显式设置为10