Skip to content

ImportError: No module named '_pywrap_tensorflow' (MSVCP140.dll is present) #7705

Closed
@SiddGururani

Description

@SiddGururani

I installed the nightly build windows 64bit release of tensorflow from http://ci.tensorflow.org/view/Nightly/job/nightly-win/85/DEVICE=gpu,OS=windows/
using pip install in the Anaconda distribution of Python 3.5 (v4.1.1.0)

When I try to import tensorflow, I get the following error:

  File "C:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 577, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 906, in create_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
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 "C:\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 66, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 21, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow')
  File "C:\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 72, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 577, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 906, in create_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
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 "C:\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 66, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 21, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow')
  File "C:\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow'

Failed to load the native TensorFlow runtime. 

I checked the msvcp140.dll and it seems to be present in multiple locations of my %PATH% (in the anaconda folder, in system32, sysWOW64 and some other locations).

I also have environment variables setup for the CUDA path.

The issue filed here: #7529 is essentially the same as mine but the user resolved it by shifting development to a VPS running Ubuntu. It still doesn't solve the problem though.

Any help would be appreciated! :)

Activity

daxlab

daxlab commented on Feb 20, 2017

@daxlab
Contributor

@SiddGururani Please try changing your directory to a directory other than the one where you installed tf.

Carmezim

Carmezim commented on Feb 20, 2017

@Carmezim
Contributor

Today is a corporate Google holiday so it might take a little to get a googler response.
So just confirming, you have the Visual C++ Redistributable 2015 x64 installed, right?
Did the suggestion above generate any result for you?

SiddGururani

SiddGururani commented on Feb 20, 2017

@SiddGururani
Author

@daxlab I tried that. Didn't help. I'm assuming you're talking about changing the working directory from where I run python and subsequently import tensorflow.

@Carmezim Yes, I checked MSVCP140.dll before trying to import tensorflow and after it failed, I did a fresh install of the VC redist package. Nothing changed.

Carmezim

Carmezim commented on Feb 20, 2017

@Carmezim
Contributor

If you want to try uninstalling TensorFlow and installing with conda install in case you need to get it running for now. The package is not officially supported though, or try installing the PYPI package with pip install tensorflow-gpu and see if it gives some result.
You have one Python distribution installed right?

SiddGururani

SiddGururani commented on Feb 20, 2017

@SiddGururani
Author

So when I use the PYPI package, it works. But gives the issues listed on #7621
The solution there was to install the nightly build. Maybe, for now I'll revert to the PYPI package.

Yes, I have one Python distribution.

Carmezim

Carmezim commented on Feb 21, 2017

@Carmezim
Contributor

Are you getting OpKernel error? There are more recent nightlies (89) if you want to try as well.

SiddGururani

SiddGururani commented on Feb 21, 2017

@SiddGururani
Author

Yes, I get the OpKernel errors with the PYPI package.

I'll try out using the latest nightly and see if it works. Shall keep you posted!

SiddGururani

SiddGururani commented on Feb 21, 2017

@SiddGururani
Author

The most recent nightly build also gave the same error.

Just to make sure I'm right in saying that the MSVCP140.dll is in the path, here is the output of:

C:\>dir msvcp140.dll /b/s
C:\Anaconda3\msvcp140.dll
C:\Anaconda3\envs\tensorflow\msvcp140.dll
C:\Anaconda3\envs\tensorflow\Library\bin\msvcp140.dll
C:\Anaconda3\Library\bin\msvcp140.dll
C:\Anaconda3\pkgs\vs2015_runtime-14.0.25123-0\msvcp140.dll
C:\Anaconda3\pkgs\vs2015_runtime-14.0.25123-0\Library\bin\msvcp140.dll
C:\ProgramFiles\CommonFiles\microsoftshared\ClickToRun\msvcp140.dll
C:\ProgramFiles(x86)\Cisco\CiscoAnyConnectSecureMobilityClient\msvcp140.dll
C:\ProgramFiles(x86)\CommonFiles\MicrosoftShared\PhoneTools\14.0\Debugger\target\armv4i\MSVCP140.dll
C:\ProgramFiles(x86)\CommonFiles\MicrosoftShared\PhoneTools\14.0\Debugger\target\x86\MSVCP140.dll
C:\ProgramFiles(x86)\CommonFiles\MicrosoftShared\PhoneTools\14.0\DiagnosticsHub\target\armv4i\msvcp140.dll
C:\ProgramFiles(x86)\CommonFiles\MicrosoftShared\PhoneTools\14.0\DiagnosticsHub\target\armv4i\Collector\msvcp140.dll
C:\ProgramFiles(x86)\CommonFiles\MicrosoftShared\PhoneTools\14.0\DiagnosticsHub\target\x86\msvcp140.dll
C:\ProgramFiles(x86)\CommonFiles\MicrosoftShared\PhoneTools\14.0\DiagnosticsHub\target\x86\Collector\msvcp140.dll
C:\ProgramFiles(x86)\MicrosoftOffice\root\Flattener\msvcp140.dll
C:\ProgramFiles(x86)\MicrosoftOffice\root\vfs\System\msvcp140.dll
C:\ProgramFiles(x86)\MicrosoftOffice\root\vfs\SystemX86\msvcp140.dll
C:\Windows\Panther\MigrationShims\MigShim1\System32\msvcp140.dll
C:\Windows\Panther\MigrationShims\MigShim1\SysWOW64\msvcp140.dll
C:\Windows\System32\msvcp140.dll
C:\Windows\SysWOW64\msvcp140.dll

And at least the Anaconda and the Windows system folders are in my %PATH%

Carmezim

Carmezim commented on Feb 21, 2017

@Carmezim
Contributor

This issue was common with Python.org distribution and not Anaconda at least AFAIK. I will comment @mrry and @gunan here if you are sure your CUDA and cuDNN are also properly set as they will know better what can be happening.

SiddGururani

SiddGururani commented on Feb 21, 2017

@SiddGururani
Author

I believe my CUDA and cuDNN are setup properly since the PYPI tensorflow-gpu package is able to find the CUDA dlls, but then it gives me the OpKernel errors.

poxvoculi

poxvoculi commented on Feb 21, 2017

@poxvoculi
Contributor

@mrry: windows build issue

mrry

mrry commented on Feb 21, 2017

@mrry
Contributor

@SiddGururani Can you check if the CUDA and cuDNN DLLs are in directories named in your %PATH%? It looks like commit 191658d changed the way the CUDA-related DLLs were loaded after the 1.0 release branch was cut, so it's possible (although I'm not exactly sure why) that the library resolution would be different in the two versions.

SiddGururani

SiddGururani commented on Feb 21, 2017

@SiddGururani
Author

Woah! So it looks like cuDNN wasn't setup properly. I put the dll, lib and .h file in CUDA's respective folders.
And it works.

SiddGururani

SiddGururani commented on Feb 21, 2017

@SiddGururani
Author

Thanks for help resolving the previous issue. When I start a new session now though, it gives me these warnings:

2017-02-21 15:24:55.373328: W c:\tf_jenkins\home\workspace\nightly-win\device\gpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.
2017-02-21 15:24:55.373452: W c:\tf_jenkins\home\workspace\nightly-win\device\gpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations.
2017-02-21 15:24:55.373552: W c:\tf_jenkins\home\workspace\nightly-win\device\gpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
2017-02-21 15:24:55.373626: W c:\tf_jenkins\home\workspace\nightly-win\device\gpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-02-21 15:24:55.373695: W c:\tf_jenkins\home\workspace\nightly-win\device\gpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-02-21 15:24:55.373764: W c:\tf_jenkins\home\workspace\nightly-win\device\gpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-02-21 15:24:55.373833: W c:\tf_jenkins\home\workspace\nightly-win\device\gpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-02-21 15:24:55.373901: W c:\tf_jenkins\home\workspace\nightly-win\device\gpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. 

Should I create a new issue for this?

40 remaining items

guitarmind

guitarmind commented on Aug 21, 2017

@guitarmind

@Innixma I did exactly the same....tried to reinstall python, CUDA, cuDNN, check environment variables so many times.

Totally misled by all public guides until I saw this issue page. Could anyone update the official installation guide of TensorFlow to mention about this for the updates after tensorflow-gpu 1.3.0?

Cody2333

Cody2333 commented on Aug 21, 2017

@Cody2333

I solve the exact problem by using Cudnn 6.0 instead of Cudnn 5.0 recently. (cudnn-8.0-windows10-x64-v6.0).

While the document metioned https://www.tensorflow.org/versions/r1.3/install/install_windows is still wrong about Cudnn's version

jbencina

jbencina commented on Aug 24, 2017

@jbencina

I spent forever on this issue only to find this open issue. Someone really needs to update the Windows guide

gunan

gunan commented on Aug 24, 2017

@gunan
Contributor

@av8ramit Can we modify the webpage to point to cudnn 6?

GPhilo

GPhilo commented on Aug 25, 2017

@GPhilo

I happened to avoid the problem because I was lucky enough to read the 1.3.0 changelog where they mention that binaries are now build against cuDNN 6.0. Time to update the install guides (there's already people on StackOverflow scratching their heads)

av8ramit

av8ramit commented on Aug 25, 2017

@av8ramit

We are in the process of updating the website right now. Thank you for your patience and sorry for any inconvenience.

2bethere

2bethere commented on Sep 11, 2017

@2bethere

Oh god....I fixed it on my machine!

You guys are right! Tensorflow 1.3 requires cudnn64_6.dll not cudnn64_7.dll

You should use the 6.0 CUDNN version with TF 1.3

into4321

into4321 commented on Sep 14, 2017

@into4321

cudnn64_6.dll work for me ,a "pan" help for me , ^o^,tks
link for cuDNN 6.0: https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v6/prod/8.0_20170307/cudnn-8.0-windows10-x64-v6.0-zip size:104M

Coderx7

Coderx7 commented on Sep 14, 2017

@Coderx7

I had the same issue today in upgrading to 1.3.0. I had both cudnnv5.1 and cudnnv6.0, but in the PATH system variable, cudnnv5.1 was used. replaced it with cudnnv6 and all errors are gone!

blistergeist

blistergeist commented on Sep 17, 2017

@blistergeist

I just wrestled with this for a couple hours (Windows 10, Anaconda 4.4.0 64 bit). I had been trying to install tensorflow-gpu using pip with no success. I followed all the guides I could find, tried using Python 3.5.3, installed cudnn 5.1 and 6.0, tried different combinations using conda environments, and still ran into the same error.

I found that installing via conda rather than pip worked the first time. Conda installed cudatoolkit, cudnn, libprotobuf, and protobuf and updated itself and vs2015_runtime.

Apparently conda is better at putting all this stuff in the right place than I am. Praise conda.

sulaimanvesal

sulaimanvesal commented on Sep 22, 2017

@sulaimanvesal

To resolve the problem in windows 10, I did the following:
1. pip uninstall tensorflow-gpu

Open Anancoda prompt with administrative access and then run the following command.
conda install tensorflow-gpu

This will take care of everything paths, cuda, cudnn and dll files and will install everything in the particular place.


Package plan for installation in environment C:\Anaconda3:

The following NEW packages will be INSTALLED:

    cudatoolkit:    8.0-1
    cudnn:          6.0-0
    libprotobuf:    3.2.0-vc14_0       [vc14]
    protobuf:       3.2.0-py35_0
    tensorflow-gpu: 1.1.0-np112py35_0
    vc:             14-0

The following packages will be UPDATED:

    astropy:        1.3.3-np111py35_0  --> 2.0.2-py35h891525e_4
    bottleneck:     1.2.1-np111py35_0  --> 1.2.1-np112py35_0
    h5py:           2.7.0-np111py35_0  --> 2.7.0-np112py35_0
    matplotlib:     2.0.2-np111py35_0  --> 2.0.2-np112py35_0
    numba:          0.33.0-np111py35_0 --> 0.33.0-np112py35_0
    numexpr:        2.6.2-np111py35_0  --> 2.6.2-np112py35_0
    numpy:          1.11.3-py35_0      --> 1.12.1-py35_0
    pandas:         0.20.1-np111py35_0 --> 0.20.3-py35_0
    pytables:       3.2.2-np111py35_4  --> 3.2.2-np112py35_4
    pywavelets:     0.5.2-np111py35_0  --> 0.5.2-np112py35_0
    scikit-image:   0.13.0-np111py35_0 --> 0.13.0-np112py35_0
    scikit-learn:   0.18.1-np111py35_1 --> 0.19.0-np112py35_0
    scipy:          0.19.0-np111py35_0 --> 0.19.1-np112py35_0
    statsmodels:    0.8.0-np111py35_0  --> 0.8.0-np112py35_0
    vs2015_runtime: 14.00.23026.0-0    --> 14.0.25420-0
    werkzeug:       0.11.4-py35_0      --> 0.12.2-py35_0

Proceed ([y]/n)? y

cudatoolkit-8. 100% |###############################| Time: 0:00:03 103.92 MB/s
cudnn-6.0-0.ta 100% |###############################| Time: 0:00:01  61.40 MB/s
vs2015_runtime 100% |###############################| Time: 0:00:00  50.37 MB/s
vc-14-0.tar.bz 100% |###############################| Time: 0:00:00 117.44 kB/s
libprotobuf-3. 100% |###############################| Time: 0:00:00  59.48 MB/s
numpy-1.12.1-p 100% |###############################| Time: 0:00:00  54.71 MB/s
werkzeug-0.12. 100% |###############################| Time: 0:00:00  32.00 MB/s
bottleneck-1.2 100% |###############################| Time: 0:00:00   6.92 MB/s
h5py-2.7.0-np1 100% |###############################| Time: 0:00:00  39.03 MB/s
numba-0.33.0-n 100% |###############################| Time: 0:00:00  54.14 MB/s
numexpr-2.6.2- 100% |###############################| Time: 0:00:00  15.75 MB/s
protobuf-3.2.0 100% |###############################| Time: 0:00:00  31.49 MB/s
pywavelets-0.5 100% |###############################| Time: 0:00:00  52.60 MB/s
scipy-0.19.1-n 100% |###############################| Time: 0:00:00  61.34 MB/s
astropy-2.0.2- 100% |###############################| Time: 0:00:00  59.28 MB/s
pandas-0.20.3- 100% |###############################| Time: 0:00:00  52.79 MB/s
pytables-3.2.2 100% |###############################| Time: 0:00:00  42.35 MB/s
scikit-learn-0 100% |###############################| Time: 0:00:00  51.41 MB/s
tensorflow-gpu 100% |###############################| Time: 0:00:01  36.20 MB/s
matplotlib-2.0 100% |###############################| Time: 0:00:00  56.54 MB/s
statsmodels-0. 100% |###############################| Time: 0:00:00  56.49 MB/s
scikit-image-0 100% |###############################| Time: 0:00:00  49.93 MB/s
Coderx7

Coderx7 commented on Sep 22, 2017

@Coderx7

@sulaimanvesal it seems conda is not up to date for the windows platform, since it installs version 1.1 which belongs to almost 5 months ago while the current version is 1.3.0!

Carmezim

Carmezim commented on Sep 22, 2017

@Carmezim
Contributor

@gunan would be a good idea to lock this thread?

gunan

gunan commented on Sep 22, 2017

@gunan
Contributor

Locking due to this becoming a catchall for unrelated windows issues.
Most of the questions here are better suited for Stackoverflow.

locked and limited conversation to collaborators on Sep 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @grimsleydl@mrry@vburca@drophit@2bethere

      Issue actions

        ImportError: No module named '_pywrap_tensorflow' (MSVCP140.dll is present) · Issue #7705 · tensorflow/tensorflow