zoukankan      html  css  js  c++  java
  • TensorFlow GPU版本号与CUDA的对应产生的错误

    前言

    感悟:cuda 8.0+cudnn 6.0+TensorFlow 1.3 
    cuda 9.0+cudnn 7.0+TensorFlow 1.7
    python3.6.2+cuda 9.0+cudnn7.5+Tensorflow 1.10.0+Anaconda4.6.11

    最近在新的工作站上重新装TensorFlow的GPU版本,刚开始由于省事,直接更新到最新版本1.13,然后输入hello TensorFlow程序。但是却报错“ImportError: DLL load failed: 找不到指定的模块”。无奈之下,各种百度,看到有个比较旧博客提议将TensorFlow版本降低到1.4,于是先卸载再重装,一顿修改之后,又报错“Could not find 'cudart64_80.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 8.0 from this URL: https://developer.nvidia.com/cuda-toolkit”,这句话的意思就是说我装的TensorFlow版本太低,只能支持CUDA8.0,但是我装的是CUDA9.0,所以出现了不对应。后来,又卸载当前TensorFlow环境,指定安装1.7版本,搞定。特此记录下来,防止后人少踩坑。

    以下图示均为命令行操作

    TensorFlow版本过低,CUDA版本过高

     具体报错如下:

    (tensorflow-gpu) C:UsersWW>python
    Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 12:30:02) [MSC v.1900 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import tensorflow
    Traceback (most recent call last):
      File "D:TensorFlowAnacondaAnacondaenvs	ensorflow-gpulibsite-packages	ensorflowpythonplatformself_check.py", line 75, in preload_check
        ctypes.WinDLL(build_info.cudart_dll_name)
      File "D:TensorFlowAnacondaAnacondaenvs	ensorflow-gpulibctypes\__init__.py", line 348, in __init__
        self._handle = _dlopen(self._name, mode)
    OSError: [WinError 126] 找不到指定的模块。
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "D:TensorFlowAnacondaAnacondaenvs	ensorflow-gpulibsite-packages	ensorflow\__init__.py", line 24, in <module>
        from tensorflow.python import *
      File "D:TensorFlowAnacondaAnacondaenvs	ensorflow-gpulibsite-packages	ensorflowpython\__init__.py", line 49, in <module>
        from tensorflow.python import pywrap_tensorflow
      File "D:TensorFlowAnacondaAnacondaenvs	ensorflow-gpulibsite-packages	ensorflowpythonpywrap_tensorflow.py", line 30, in <module>
        self_check.preload_check()
      File "D:TensorFlowAnacondaAnacondaenvs	ensorflow-gpulibsite-packages	ensorflowpythonplatformself_check.py", line 82, in preload_check
        % (build_info.cudart_dll_name, build_info.cuda_version_number))
    ImportError: Could not find 'cudart64_80.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 8.0 from this URL: https://developer.nvidia.com/cuda-toolkit

    TensorFlow版本过高,CUDA版本过低

     具体错误如下所示:

    (tensorflow-gpu) C:UsersWW>python
    Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 12:30:02) [MSC v.1900 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import tensorflow
    Traceback (most recent call last):
      File "D:TensorFlowAnacondaAnacondaenvs	ensorflow-gpulibsite-packages	ensorflowpythonpywrap_tensorflow.py", line 58, in <module>
        from tensorflow.python.pywrap_tensorflow_internal import *
      File "D:TensorFlowAnacondaAnacondaenvs	ensorflow-gpulibsite-packages	ensorflowpythonpywrap_tensorflow_internal.py", line 28, in <module>
        _pywrap_tensorflow_internal = swig_import_helper()
      File "D:TensorFlowAnacondaAnacondaenvs	ensorflow-gpulibsite-packages	ensorflowpythonpywrap_tensorflow_internal.py", line 24, in swig_import_helper
        _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
      File "D:TensorFlowAnacondaAnacondaenvs	ensorflow-gpulibimp.py", line 242, in load_module
        return load_dynamic(name, filename, file)
      File "D:TensorFlowAnacondaAnacondaenvs	ensorflow-gpulibimp.py", line 342, in load_dynamic
        return _load(spec)
    ImportError: DLL load failed: 找不到指定的模块。
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "D:TensorFlowAnacondaAnacondaenvs	ensorflow-gpulibsite-packages	ensorflow\__init__.py", line 24, in <module>
        from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
      File "D:TensorFlowAnacondaAnacondaenvs	ensorflow-gpulibsite-packages	ensorflowpython\__init__.py", line 49, in <module>
        from tensorflow.python import pywrap_tensorflow
      File "D:TensorFlowAnacondaAnacondaenvs	ensorflow-gpulibsite-packages	ensorflowpythonpywrap_tensorflow.py", line 74, in <module>
        raise ImportError(msg)
    ImportError: Traceback (most recent call last):
      File "D:TensorFlowAnacondaAnacondaenvs	ensorflow-gpulibsite-packages	ensorflowpythonpywrap_tensorflow.py", line 58, in <module>
        from tensorflow.python.pywrap_tensorflow_internal import *
      File "D:TensorFlowAnacondaAnacondaenvs	ensorflow-gpulibsite-packages	ensorflowpythonpywrap_tensorflow_internal.py", line 28, in <module>
        _pywrap_tensorflow_internal = swig_import_helper()
      File "D:TensorFlowAnacondaAnacondaenvs	ensorflow-gpulibsite-packages	ensorflowpythonpywrap_tensorflow_internal.py", line 24, in swig_import_helper
        _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
      File "D:TensorFlowAnacondaAnacondaenvs	ensorflow-gpulibimp.py", line 242, in load_module
        return load_dynamic(name, filename, file)
      File "D:TensorFlowAnacondaAnacondaenvs	ensorflow-gpulibimp.py", line 342, in load_dynamic
        return _load(spec)
    ImportError: DLL load failed: 找不到指定的模块。
    
    
    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与CUDA版本的对应关系

    附上几张表格:

    具体最新版本对应可参考TensorFlow中文网址:https://www.tensorflow.org/install/source#tested_source_configurations

    总结

    1. 安装环境时参考的博客一定要注意时间,时间,时间。有可能当时可以的现在就不一定行了,版本问题真的很烦人呐呐呐
    2. 切勿贪图省事,更新到最新版本,要提前了解清楚,然后再装对应的版本

    参考

    https://blog.csdn.net/yeler082/article/details/80943040

  • 相关阅读:
    tomcat对sessionId的处理分析
    MySQL 5.5 新增SIGNAL异常处理
    jetty对sessionId的处理分析
    Python3.x和Python2.x的区别
    java actor模型和消息传递简单示例
    构建工具scons让一切变得简单
    HTML元素控件事件表
    开始新的旅途
    JS各种常见知识点
    C#代码与javaScript函数的相互调用
  • 原文地址:https://www.cnblogs.com/ipersevere/p/10784262.html
Copyright © 2011-2022 走看看