本文介绍了Tensorflow导入错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试安装支持GPU的tensorflow。

I'm trying to install tensorflow which supports GPU.

我尝试了以下链接中的信息

I tried the information in the following link


  1. CUDA®Toolkit 8.0

  2. cuDNN v6.0

  3. GPU卡具有CUDA计算能力3.0-GeForce 940MX

然后使用 pip3 install --upgrade tensorflow-gpu 安装tensorflow。

Then used pip3 install --upgrade tensorflow-gpu to install tensorflow.

但是尝试导入tensorflow时出现以下错误。

But I'm getting the following error when trying to import tensorflow.

    Traceback (most recent call last):
      File "C:\Research\Python_installation\lib\site-packages\tensorflow\python\platform\self_check.py", line 75, in preload_check
        ctypes.WinDLL(build_info.cudart_dll_name)
      File "C:\Research\Python_installation\lib\ctypes\__init__.py", line 347, in __init__
        self._handle = _dlopen(self._name, mode)
    OSError: [WinError 126] The specified module could not be found

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<pyshell#6>", line 1, in <module>
        import tensorflow as tf
      File "C:\Research\Python_installation\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
        from tensorflow.python import *
      File "C:\Research\Python_installation\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
        from tensorflow.python import pywrap_tensorflow
      File "C:\Research\Python_installation\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 30, in <module>
        self_check.preload_check()
      File "C:\Research\Python_installation\lib\site-packages\tensorflow\python\platform\self_check.py", line 82, in preload_check
        % (build_info.cudart_dll_name, build_info.cuda_version_number))
    ImportError: Could not find 'cudart64_90.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 9.0 from this URL: https://developer.nvidia.com/cuda-toolkit

有人可以给我建议如何使用它。

Can someone please advice me on how to use this.

推荐答案

我有一个类似的问题,必须非常小心CUDA版本和CuDNN版本。我遇到了您要遇到的确切错误,并通过查看此处记录的内容进行了修复:

I had a similar problem, and had to be very careful about the version of CUDA, and the version of CuDNN. I hit the exact error you are hitting, and fixed it by going through what I documented here: http://www.laurencemoroney.com/installing-tensorflow-with-gpu-on-windows-10/

给试试看! :)

(我发现的最常见故障是您下载了最新 CUDA,而不是匹配 CUDA。现在CUDA是9.1,但是TF需要9.0(您的错误是cudart90.dll),因此找到9.0驱动程序,下载并安装它们。然后运行TensorFlow。然后,它可能在CuDNN驱动程序上失败,这很好,因为您知道CUDA是正确的。然后下载正确的CuDNN驱动程序(与错误中的版本号匹配),然后重试。)

(The most common failure I've found is that you download the latest CUDA, and not the matching CUDA. Right now CUDA is at 9.1, but TF requires 9.0 -- your error says cudart90.dll) -- so find the 9.0 drivers, download and install them. Then run TensorFlow. It might then fail on the CuDNN drivers, which is good, becuase you know CUDA is right. Then download the right CuDNN drivers (matching the version # in the error) and try again.)

这篇关于Tensorflow导入错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 21:11