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)
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.
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).
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.
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
you have a file C:\Windows\System32\MSVCP140.DLL, AND
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.
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.
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
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
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)
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.
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
I posted a general approach for troubleshooting the "DLL load failed" problem in this post on Windows systems. For reference:
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.
Look for information of the missing DLL and install the appropriate package to resolve the problem.
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.
[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).
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
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: