90

On Windows, TensorFlow reports either or both of the following errors after executing an import tensorflow statement:

  • No module named "_pywrap_tensorflow"
  • DLL load failed.
Barry Rosenberg
  • 2,117
  • 4
  • 15
  • 18

23 Answers23

79

The problem was the cuDNN Library for me - for whatever reason cudnn-8.0-windows10-x64-v6.0 was NOT working - I used cudnn-8.0-windows10-x64-v5.1 - ALL GOOD!

My setup working with Win10 64 and the Nvidia GTX780M:

  • Be sure you have the lib MSVCP140.DLL by checking your system/path - if not get it here
  • Run the windows installer for python 3.5.3-amd64 from here - DO NOT try newer versions as they probably won't work
  • Get the cuDNN v5.1 for CUDA 8.0 from here - put it under your users folder or in another known location (you will need this in your path)
  • Get CUDA 8.0 x86_64 from here
  • Set PATH vars as expected to point at the cuDNN libs and python (the python path should be added during the python install)
  • Make sure that ".DLL" is included in your PATHEXT variable
  • If you are using tensorflow 1.3 then you want to use cudnn64_6.dll github.com/tensorflow/tensorflow/issues/7705

If you run Windows 32 be sure to get the 32 bit versions of the files mentioned above.

Santiago Gil
  • 1,292
  • 7
  • 21
  • 52
DropHit
  • 1,695
  • 15
  • 28
  • 8
    It may be obvious to most but the CUDA DLL is 'cudnn64_5.dll' and the folder it is in needs to be in the path.. not the parent folder. I dropped it in '%USERPROFILE%\AppData\Local\cuda\bin;' – Awesomeness May 04 '17 at 00:17
  • 6
    After you add to the PATH remember to close your command prompt and open it again. Also, it's worth typing "cudnn64_5.dll" into your command prompt to make sure you got the path settings right. – Sean Colombo May 11 '17 at 18:53
  • 1
    Thank you for saving my time. – J.J. Kim Jul 04 '17 at 06:06
  • 9
    I just spent 4 hours debugging this, if you are using tensorflow 1.3 then you want to use cudnn64_6.dll https://github.com/tensorflow/tensorflow/issues/7705 – Chris Barrett Aug 20 '17 at 07:04
  • 1
    Also just spent hours on this. If you use tensorflow 1.3 you will have to download cuDNN v6.0 even though Tensorflow's instructions specifically say you have to use 5.1 – Frobot Aug 24 '17 at 00:46
  • 2
    Chris Barret's comment solved it - if you are installing after Aug 2017 chances are you'll need cuDNN v6,0 not 5 or 7. – Reddspark Sep 10 '17 at 06:19
  • 2
    In my case, python 3.5.4 also worked. And I wasn't able to install cuda 8.0 until remove vs17 and install visual studio 15(win10). It's really ridiculous that I had to find and install old versions one by one. – margincall Sep 14 '17 at 21:31
  • 1
    Thanks for the help, here is my working setup as of November 1st, 2017: - Windows 10 Pro x64 - MS Visual Studio Community 2017 15.4.2, for MSVC++2015 redist., any >14.0 is ok - python 3.6.3, from chocolatey - tensorflow-gpu 1.3.0, from pip, use it w/out CPU pkg or install GPU 2nd - CUDA 8.0, from https://developer.nvidia.com/cuda-toolkit-archive - cuDNN 6.0, from https://developer.nvidia.com/rdp/cudnn-download, copy files to CUDA directories Reinstalling CUDA 8.0 *without newer versions installed* was key for me. FYI tensorflow (1.3) dependency versions might change in the future – Pregnor Nov 01 '17 at 08:37
  • 1
    Had the same problem, nothing fixed it. Resorted to installing Anaconda (which i dont like) but it is working through the Spider app found in the Anaconda Navigator program. Hope this helps. – JohnPaul Mar 30 '18 at 11:04
  • 1
    Perhaps this is obvious, but I assume you do not install cuDNN if you are not running with a GPU. – kibitzforu Sep 03 '18 at 21:00
  • 1
    I resolved the same issue thanks to this tuto https://www.youtube.com/watch?v=HRaRi6f5Qcs (installing tensorflow for sse) – SciPy Sep 06 '20 at 10:19
  • 1
    ? as I understood: first & foremost graphics cards (or videocard) should support CUDA, if not - then neither of advised ways will help. Anyway thank you for your recommendations - am still having this error – JeeyCi Apr 11 '22 at 12:53
22

In my case the "cudnn64_6.dll" file in the /bin folder had to be renamed to "cudnn64_5.dll" for the error to go away. I easily spent two hours to figure this out, and I followed the official install guide to the letter. This is true for installation via pip (officially supported) and conda (community supported).

Vitaly
  • 4,358
  • 7
  • 47
  • 59
  • 1
    This was my case. TensorFlow requires "cuDNN v5.1" but if you install cuDNN v6.0, then the file name of the cudnn dll file will be `cudnn64_6.dll` not `cudnn64_5.dll`. – Naetmul Jun 13 '17 at 12:17
  • 1
    If you are using tensorflow 1.3 then you want to use cudnn64_6.dll https://github.com/tensorflow/tensorflow/issues/7705 – Chris Barrett Aug 20 '17 at 07:05
  • I am using tensorflow 1.3 and I had to change from cudnn64_7.dll (newest version right now) to cudnn64_6.dll as @ChrisBarrett says to make it work. – Javier Cabero Sep 10 '17 at 18:28
  • 1
    In case of tensorflow 1.3 and cudNN 7, similarly renaming `cudnn64_7.dll` to `cudnn64_6.dll` helps. – Smarty77 Oct 10 '17 at 20:51
13

Either error indicates that your system has not installed MSVCP140.DLL, which TensorFlow requires.

To fix this error:

  1. Determine whether MSVCP140.DLL is in your %PATH% variable.
  2. If MSVCP140.DLL is not in your %PATH%, install the Visual C++ 2015 redistributable (x64 version), which contains this DLL.
Improv
  • 178
  • 1
  • 6
Barry Rosenberg
  • 2,117
  • 4
  • 15
  • 18
  • 1
    This may or may not fix his issue (depending on CPU vs GPU) and although the windows dll is needed it could be another issue as well - see answer below. I had no issues with the windows dll but instead had an issue with cuDNN v6.0 – DropHit Apr 23 '17 at 01:04
  • 8
    You can checked if MSVCP140.dll is in your path by typing the following at the command prompt: where MSVCP140.DLL –  May 06 '17 at 01:29
  • 1
    The link takes you to the 2010 version. Are we aiming for the 2015 or 2010 version? – DAG Oct 05 '17 at 17:02
  • [In my case](https://stackoverflow.com/questions/64944065/tensorflow-importerror-dll-load-failed-while-importing-pywrap-tensorflow-inter#69874313) (TF 2.5.0) a different DLL `vcruntime140_1.dll` was missing - but thanks to your answer, it gave me a clue where to look! – Janaka Bandara Nov 07 '21 at 16:35
12

I have Win7 Pro 64-bit on AMD cpu, no gpu. I was following the instructions under "Installing with native pip" at https://www.tensorflow.org/install/install_windows. The installation step went ok but the attempt to import tensorflow produced the infamous:

ImportError: No module named '_pywrap_tensorflow_internal'

This seems to be one of those situations where a lot of unrelated things can go wrong, depending on configuration, which all cascade through to the same error.

In my case, installing MSVCP140.DLL was the answer.

You have MSVCP140.DLL already if

  1. you have a file C:\Windows\System32\MSVCP140.DLL, AND
  2. if you have a 64 bit system, then you additionally have C:\Windows\SysWOW64\MSVCP140.DLL.

I installed it manually, which was unnecessary (the redistributable is not the whole Visual C++ development mess and isn't large). Use the link posted earlier in this thread to install it: Visual C++ 2015 redistributable.

Also, I recommend that you override the default install directory for Python and put it anywhere not under C:\Program Files, because Windows tries to write-protect files there, which causes problems later.

Cadoiz
  • 1,446
  • 21
  • 31
JWG
  • 151
  • 1
  • 6
11

For tensorflow with CPU only:


I had installed tensorflow using command:

pip3 install --upgrade tensorflow

This installed tensorflow 1.7
But could not import the tensorflow from withing python 3.6.5 amd64 using:

import tensorflow as tf

So, i downgraded the tensorflow version from 1.7 to 1.5 using following command:

pip3 install tensorflow==1.5

This uninstalled the previous version and installed 1.5. Now it works.

Seems that, my CPU does not support AVX instruction set that is needed in tensorflow 1.7

I had MSVCP140.DLL in the system folders and .DLL in the PATHEXT variable in Environment Variable.

Rakibul Haq
  • 1,348
  • 23
  • 32
  • my system: Windows 8.1, Python 3.6.5 64 Bit, No GPU. – Rakibul Haq Apr 09 '18 at 10:39
  • Might have to be updated, as since version 2.0.0, tensorflow-gpu is integrated into the regular installation - see here: https://github.com/fo40225/tensorflow-windows-wheel Maybe you want to consider my answer here where the compatibility between different versions of python and tensorflow is explained: https://stackoverflow.com/questions/45749992/how-to-downgrade-tensorflow-multiple-versions-possible/62855139#62855139 – Cadoiz Jul 11 '20 at 22:48
8

TensorFlow requires MSVCP140.DLL, which may not be installed on your system. To solve it open the terminal en type or paste this link:

C:\> pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.0.0-cp35-cp35m-win_amd64.whl 

Note this is to install the CPU-only version of TensorFlow.

Fahtima
  • 401
  • 1
  • 3
  • 9
  • For my configuration, the binary that worked was: https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.4.0-cp36-cp36m-win_amd64.whl -- Check https://pypi.python.org/pypi/tensorflow for available built binaries. I checked for a couple of them until the "import tensorflow as tf" succeed. – David Dec 07 '17 at 11:09
8

cuDNN causes my problem. PATH variable doesn't work for me. I have to copy the files in my cuDNN folders into respectful CUDA 8.0 folder structure.

Chris Han
  • 81
  • 1
  • 3
6

For Those Running on Older Hardware:

You may get this same error due to having an older CPU using tensorflow-gpu 1.6.

If your cpu was made before 2011, then your max tensorflow-gpu version is 1.5.

Tensorflow 1.6 requires AVX instructions on your cpu. Verified here: Tensorflow Github docs

AVX enabled CPUs: Wiki AVX CPUs

What I did in my conda environment for tensorflow:

pip install --ignore-installed --upgrade tensorflow-gpu==1.5
Jasen
  • 471
  • 5
  • 5
5

I posted a general approach for troubleshooting the "DLL load failed" problem in this post on Windows systems. For reference:

  1. Use the DLL dependency analyzer Dependencies to analyze <Your Python Dir>\Lib\site-packages\tensorflow\python\_pywrap_tensorflow_internal.pyd and determine the exact missing DLL (indicated by a ? beside the DLL). The path of the .pyd file is based on the TensorFlow 1.9 GPU version that I installed. I am not sure if the name and path is the same in other TensorFlow versions.

  2. Look for information of the missing DLL and install the appropriate package to resolve the problem.

Cadoiz
  • 1,446
  • 21
  • 31
GZ0
  • 4,055
  • 1
  • 10
  • 21
  • 1
    I like this approach since it explicitly shows which dlls are missing. Found out that tensorflow 1.11 is looking for CUDA 9 dlls and seems not to search for CUDA 10 libraries. – padmalcom Oct 13 '18 at 08:55
  • 1
    Thank you so much for your suggestion! On my machine the problem was that tensorflow was looking for DLL's that come with CUDA tookit v9, but I installed CUDA toolkit v10 – Floris Devreese Nov 09 '18 at 15:00
  • This is incredibly useful. Notice that you have to select `All files (*.*)` next to file name instead of just `exe files (*.exe, *.dll)`. – Cadoiz Jul 11 '20 at 14:36
  • Excellent tip! [In my case](https://stackoverflow.com/questions/64944065/tensorflow-importerror-dll-load-failed-while-importing-pywrap-tensorflow-inter#69874313) I found my TF 2.5.0 install was requesting an additional `vcruntime140_1.dll` beyond what is usually documented online – Janaka Bandara Nov 07 '21 at 16:31
4

The problem for me was the cuDNN library which didn't match the requirements of the graphics card. I downloaded the 6.0 version but for my GTX980ti but the recommended compute capability on the nvidia website was 5.1 ( http://developer.nvidia.com/cuda-gpus ) so I downloaded 5.1 and replaced the 6.0 version and as soon as I've done that it started working.

Remus.A
  • 92
  • 1
  • 9
4

After much trial and error, and making sure VC++ 2015 Redistributable, cuDNN DLL and all other dependencies are accessible from PATH, it looks like Tensorflow GPU works only with Python 3.5.2 (as of this writing)

So if you're using Anaconda

  • conda create -n tensorflow-gpu python=3.5.2
  • activate tensorflow-gpu
  • pip install tensorflow-gpu

Then open the python interpreter and verify

>>> import tensorflow as tf
>>> sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

Found device 0 with properties:
name: GeForce 940M
major: 5 minor: 0
memoryClockRate (GHz) 1.176
pciBusID 0000:06:00.0
Total memory: 2.00GiB
Free memory: 1.66GiB

Credits: this neat guide

Madhur
  • 2,119
  • 1
  • 24
  • 31
4

For each Tensorflow's version, it requires different version of CuDnn. On www.tensorflow.org, they did not mentioned about that in installation guide!

My case use tensorflow version 1.3 which uses cuDNN 6. https://github.com/tensorflow/tensorflow/releases.

Please check your tensorfow version and cuDNN version if they are match together.

And please set path environment for cuDNN, if it still does not work, please check the answer from @Chris Han.

Cadoiz
  • 1,446
  • 21
  • 31
nguyenhoai890
  • 1,189
  • 15
  • 20
2

One may be tempted to keep the Powershell/cmd open on Windows. I've spent reasonable time till I decided to close and reopen my Powershell only to realize that I've done everything right.

Victor Silva
  • 306
  • 2
  • 15
2

In case you are trying to install tensorflow GPU in Windows, you can find this easy interesting tutorial.

Note: If you are using PyCharm for example, you have to change the interpreter to the created conda environment.

Wesam Na
  • 2,364
  • 26
  • 23
2

For the people finding this post in 2019, this error could also occur because the Python version 3.7 does not have support for TensorFlow (see https://www.tensorflow.org/install/pip). So, check the Python version:

python --version

In case it is larger than 3.6, it should be downgraded to 3.6. For Anaconda:

conda install python=3.6

Then, install TensorFlow.

pip install tensorflow

Btw, I did not have the GPU version, so there were no CUDA related issues in my case.

Catalin Stoean
  • 131
  • 3
  • 6
1

Dll not found. Install Visual C++ 2015 redistributable to fix.

glee8e
  • 6,180
  • 4
  • 31
  • 51
  • Not sure this covers it exactly - depending on scenario - see above answer related to cuDNN v6.0 - also may want to include the link to the lib you mention (which i will do right here https://www.microsoft.com/en-us/download/details.aspx?id=48145 vs this quick blurb :) – DropHit Apr 23 '17 at 01:09
1

The problem was the cuDNN Library for me. I was able to run the test code after adding the directory (possibly bin folder) of the cuDNN DLL (not LIB file) in the Windows PATH.

For the reference, I installed TensorFlow from the source using PIP and my OS: Windows 7 and IDE: Visual Studio 2015.

Cloud Cho
  • 1,594
  • 19
  • 22
1

With TensorFlow release 1.3.0, you need to use Cudnn 6.0 instead of Cudnn 5.0 as Cudnn 5.0 is giving this error. Don't forget to add path variable to Cudnn 6.0 .With cudnn64_6.dll your Tensorflow will work fine. Read the link below. https://github.com/tensorflow/tensorflow/blob/master/RELEASE.md#release-130

Shivam Panwar
  • 396
  • 1
  • 3
  • 9
1

My two cents:

I had a ton of problems trying to get my CUDA 8.0 installed properly on Windows 7. I had a previous version installed and I wanted to upgrade so I uninstalled it and tried to install CUDA 8.0 (for tensorflow 1.3). The installation failed every single time, I tried to downgrade to CUDA 7.5 and was able to install it but had a ton of problems with tensorflow (similar to the PATH problem described here). Long story short: what worked for me was:

1) Uninstall EVERY NVIDIA component (except the display graphics driver)

2) Download CUDA toolkit 8.0 (and the patch) https://developer.nvidia.com/cuda-downloads

3) Check the CheckSum MD5 (I used MS https://www.microsoft.com/en-ca/download/confirmation.aspx?id=11533 but any would do) to make sure they were OK (it happened several times that the installer was not dowloaded properly because my WiFi router apparently).

4) Run the CUDA toolkit installer as root

5) download the cudnn 8.0 v6 and add its location to the PATH variable https://developer.nvidia.com/rdp/cudnn-download

Hope that helps and saves some headaches...

NOTE: This script helped me a lot to debug the problem! (Thank you mrry) https://gist.github.com/mrry/ee5dbcfdd045fa48a27d56664411d41c

edgarbc
  • 366
  • 2
  • 15
1

I will try to give the solution that worked for me. It seems that different set of problems can lead to this situation.

32 bit software works in 64 bit OS. I installed anaconda-3 (32 bit) in my 64 bit OS. It was working perfectly fine. I decided to install tensorflow in my machine and it wouldn't install at first. I was using conda environment to install tensorflow and got this error.

Solution is if you are running 64 bit OS, install 64 bit anaconda and if 32 bit OS then 32 bit anaconda. Then follow the standard procedure mentioned in tensorflow website for windows (anaconda installation). This made it possible to install tensorflow without any problem.

user2736738
  • 30,591
  • 5
  • 42
  • 56
1

my answer is for windows 10 users only as I have tried the following on windows 10. Extending some of the answers above I suggest this : If you are using anaconda then you can avoid everything and simply install anaconda-navigator using the command

conda install -c anaconda anaconda-navigator

Then you can launch the navigator from command prompt using the command

anaconda-navigator

On running this command you get a simple gui where you can create an virtual environment, create the environment with python=3.5.2 and install module tensorflow-gpu or tensorflow by searching the module in the search box using gui, it will also take care of installing correct cuda files for you. Using anaconda navigator is the simplest solution.

If you are not using anaconda then take care about the following

tensorflow-gpu 1.3 requires python 3.5.2, cuda development kit 8.0 and cudaDNN 6.0, hence when installing make sure you run the command

pip install tensorflow-gpu==1.3

tensorflow-gpu 1.2.1 or less requires python 3.5.2, cuda development kit 8.0 and cudaDNN 5.1 hence when installing make sure you run the command

pip install tensorflow-gpu==1.2.1

Below are the steps you need to follow for both of the above processes Setting up you path variables You must have the following system variables

CUDA_HOME = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0"
CUDA_PATH = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0"
CUDA_PATH_V8.0 = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0"

You PATHTEXT must include ".DLL" along with other extensions

".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.DLL"

Also Add the following to you path

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\extras\CUPTI\libx64;
C:\Windows\SysWOW64;
C:\Windows\System32        

If you are getting errors you can download the run the below code by mrry, this code will check your setup and tell you if something is wrong https://gist.github.com/mrry/ee5dbcfdd045fa48a27d56664411d41c

References : http://blog.nitishmutha.com/tensorflow/2017/01/22/TensorFlow-with-gpu-for-windows.html

The above reference is very useful. Please comment for improvements to this answer. Hope this helps, Thanks.

M2skills
  • 301
  • 1
  • 5
  • 19
  • The anaconda option sounds great, but looking at https://anaconda.org/anaconda/tensorflow-gpu the tensorflow-gpu version for windows seems to be 1.1, any way to get the 1.3 through anaconda? – ftiaronsem Oct 26 '17 at 14:01
  • @ftiaronsem There is no way to install 1.3 using the anaconda-navigator if you want 1.3 then follow the reference link and make a note to use cudaDNN 6.0 – M2skills Oct 28 '17 at 05:25
1

tensorflow 1.3 does not support cuda 9.0 yet. I degrade to cuda 8.0, then it works.

yichudu
  • 165
  • 2
  • 12
1

Ran into the same problem (in 20190909) while investigating [SO]: Error while training using the estimator API in tensorflow.

Setup:

Error:

[cfati@CFATI-5510-0:e:\Work\Dev\StackOverflow\q057588589]> "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\Scripts\python.exe" -c "import tensorflow as tf"
Traceback (most recent call last):
  File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\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 "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\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 "<string>", line 1, in <module>
  File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\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 "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\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.

Looking at the "faulty" module (thanks to Dependency Walker), it turns out that it's not itself that's missing, but some of its dependencies (the cu*_100.dll files).

Img0

Check [SO]: Python Ctypes - loading dll throws OSError: [WinError 193] %1 is not a valid Win32 application (@CristiFati's answer) (the Conclusions section at the end, and (referenced) [SO]: Discover missing module using command-line ("DLL load failed" error) (@CristiFati's answer)) for more details on this kind of errors.
I had an older CUDA Toolkit version (8), and as a consequence, the cu*_80.dll files.

Upgrading to TensorFlow-GPU 1.14.0 ("e:\Work\Dev\VEnvs\py_064_03.07.03_test0\Scripts\python.exe" -m pip install --upgrade tensorflow-gpu), made the error a bit clearer (and also shorter):

[cfati@CFATI-5510-0:e:\Work\Dev\StackOverflow\q057588589]> "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\Scripts\python.exe" -c "import tensorflow as tf"
Traceback (most recent call last):
  File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\python\platform\self_check.py", line 75, in preload_check
    ctypes.WinDLL(build_info.cudart_dll_name)
  File "c:\install\x64\python\python\03.07.03\Lib\ctypes\__init__.py", line 356, 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 "<string>", line 1, in <module>
  File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\__init__.py", line 28, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 30, in <module>
    self_check.preload_check()
  File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\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_100.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 10.0 from this URL: https://developer.nvidia.com/cuda-90-download-archive

Steps:

  • Uninstall any CUDA Toolkit version (optional)

  • Install [nVidia.Developer]: CUDA Toolkit 10.0 Archive

    • Make sure to install v10.0 (that this TensorFlow-GPU version was built against - check [TensorFlow]: Build from source on Windows - GPU). I installed v10.1 (which was the latest, and also the recommended version at the answer time), and the .dll names didn't match (cu*_101.dll). Since I didn't want to install v10.0, I created some symlinks (with the "correct" names) to the existing files, and it worked. But bear in mind that this is unsupported!!! You may experience funny behavior (including crashes). This is a (lame) workaround (gainarie)

    • Additionally, a compatible (meaning that it's for a specific CUDA Toolkit version) cuDNN version ([nVidia.Developer]: cuDNN Archive) is required. In order to access the download URL, nVidia membership is required

After the above steps, and also setting the correct paths, it worked:

[cfati@CFATI-5510-0:e:\Work\Dev\StackOverflow\q057588589]> set PATH=%PATH%;%CUDA_PATH%\bin;f:\Install\x64\NVidia\GPU Computing Toolkit\cuDNN\7.6\bin

[cfati@CFATI-5510-0:e:\Work\Dev\StackOverflow\q057588589]> "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\Scripts\python.exe" -c "import tensorflow;print(\"Success!!!\")"
Success!!!
CristiFati
  • 38,250
  • 9
  • 50
  • 87