Tensorflow import error

10,996

Solution 1

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/

Give it a try! :)

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

Solution 2

Please download the proper drivers as latest version of cuda v8.0 toolkit needs tensorflow 1.4.x needs.

As, by default pip3 install --upgrade tensorflow-gpu install latest version of tensorflow which needs cuda v9.0 (latest) not cuda v8.0 toolkit

You'll need to install the version 1.4.1 for CUDA-8 as

pip install tensorflow-gpu==1.4.1

The latest (version 1.5) is for CUDA-9 You'll need to install the version 1.5 for CUDA-9 as

pip install tensorflow-gpu==1.5

Download cuddn for your appropriate cuda version toolkit from here and follow this.

Download appropriate cuda toolkit from here

Share:
10,996
user3789200
Author by

user3789200

Updated on July 25, 2022

Comments

  • user3789200
    user3789200 almost 2 years

    I'm trying to install tensorflow which supports GPU.

    I tried the information in the following link

    https://www.tensorflow.org/install/install_windows

    1. CUDA® Toolkit 8.0
    2. cuDNN v6.0
    3. GPU card with CUDA Compute Capability 3.0 - GeForce 940MX

    Then used pip3 install --upgrade tensorflow-gpu to install 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.

  • user924
    user924 almost 6 years
    well I have correct versions, I have those dll, but I still get this error, details: github.com/EdjeElectronics/…
  • Laurence Moroney
    Laurence Moroney almost 6 years
    Weird...I noticed that your issue is with the 64 bit version of cudart90 -- I'm wondering if there's something different there. Are you sure you uninstalled all CUDA post 9.0, then rebooted, then installed 9.0?
  • user924
    user924 almost 6 years
    Yes, I have only Cuda 9.0 in "program files", "environment variables" and in "app and features"
  • JakeJ
    JakeJ almost 6 years
    Thank you very much. This was exactly what I needed to align the versions and get the tensorflow module imported to python.