Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: No module named '_pywrap_tensorflow_internal' #9469

Closed
quatre008 opened this issue Apr 27, 2017 · 33 comments

Comments

Projects
None yet
@quatre008
Copy link

commented Apr 27, 2017

Hi all,

Using windows 7 and have made tensorflow work in the cpu version. But keep getting this error in the gpu version.

Installed it using pip install tensorflow-gpu. Have cuda 8.0 and cudnn 5.1. Have the dll file and cudnn files copied over. GPU model is K610M.

Thanks in advance for the assistance.

Capture of the screen:
(C:\Users\KiraYamato\Anaconda3) C:\Users\KiraYamato>activate tensorflow-gpu

(tensorflow-gpu) C:\Users\KiraYamato>python
Python 3.5.3 |Continuum Analytics, Inc.| (default, Feb 22 2017, 21:28:42) [MSC v
.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

import tensorflow as tf
Traceback (most recent call last):
File "C:\Users\KiraYamato\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tens
orflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\KiraYamato\Anaconda3\envs\tensorflow-gpu\lib\importlib_init_
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 914, in create_module
File "", line 222, in _call_with_frames_removed
ImportError: DLL load failed: The specified procedure could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\KiraYamato\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tens
orflow\python\pywrap_tensorflow.py", line 41, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\KiraYamato\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tens
orflow\python\pywrap_tensorflow_internal.py", line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\KiraYamato\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tens
orflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('pywrap_tensorflow_internal')
File "C:\Users\KiraYamato\Anaconda3\envs\tensorflow-gpu\lib\importlib_init

.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "C:\Users\KiraYamato\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tens
orflow_init_.py", line 24, in
from tensorflow.python import *
File "C:\Users\KiraYamato\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tens
orflow\python_init_.py", line 51, in
from tensorflow.python import pywrap_tensorflow
File "C:\Users\KiraYamato\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tens
orflow\python\pywrap_tensorflow.py", line 52, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\KiraYamato\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tens
orflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\KiraYamato\Anaconda3\envs\tensorflow-gpu\lib\importlib_init_
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 914, in create_module
File "", line 222, in _call_with_frames_removed
ImportError: DLL load failed: The specified procedure could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\KiraYamato\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tens
orflow\python\pywrap_tensorflow.py", line 41, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\KiraYamato\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tens
orflow\python\pywrap_tensorflow_internal.py", line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\KiraYamato\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tens
orflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('pywrap_tensorflow_internal')
File "C:\Users\KiraYamato\Anaconda3\envs\tensorflow-gpu\lib\importlib_init

.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'

Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_probl
ems

for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.

@kdexd

This comment has been minimized.

Copy link
Contributor

commented Apr 27, 2017

Hi @quatre008,
As the stack overflow link suggests, have you tried to invoke tensorflow by staying out of the source code directory?

@Carmezim

This comment has been minimized.

Copy link
Contributor

commented Apr 27, 2017

Hi @quatre008, sorry you're facing issues, could you please check if your CUDA and cuDNN DLLs are properly set on your %PATH%?

@quatre008

This comment has been minimized.

Copy link
Author

commented Apr 27, 2017

Hi,

@karandesai-96 I tried many different directories and still the same. Tensorflow worked but not tensorflow gpu.

@Carmezim How do I know if it is properly set? I only found the following:
PATH: C:\Users\KiraYamato\Anaconda3;C:\Users\KiraYamato\Anaconda3\Scripts;C:\Users\KiraYamato\Anaconda3\Library\bin
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

@Carmezim

This comment has been minimized.

Copy link
Contributor

commented Apr 27, 2017

@quatre008 what happens sometimes is that cuDNN DLLs are installed in a different directory of CUDA so you need to add it also. Make sure you installed cuDNN correctly and if its DLLs are not in those directories already in your %PATH% you need to add them.

@quatre008

This comment has been minimized.

Copy link
Author

commented Apr 27, 2017

@Carmezim I have copied the files into the same CUDA directory as mentioned. So I am guessing it should be working fine. I have re-downloaded and overwritten to make sure this was the case too.

@Carmezim

This comment has been minimized.

Copy link
Contributor

commented Apr 27, 2017

@quatre008 If you went over CUDA and cuDNN installation again and made sure you have everything properly set, completely uninstall TensorFlow and install it (only GPU) again. If the problem persists then it's not CUDA/cuDNN related.

@quatre008

This comment has been minimized.

Copy link
Author

commented Apr 27, 2017

Ok I finally managed to resolve the issue.

2 issues at work here. One being my Visual Studio was not installed properly, and the second one (outside of this topic but still interesting) is that my laptop has dual graphics boot-up.

So for the first issue, I managed to resolve it by deleting most folders and restarting the installation, starting from visual studio (the free version of community VS2017 did not work previously).

Then as for the second issue, I only need to remove intel graphics from the bootup menu and solely use the K610M that I am having and everything is fine now, except for a list of warning messages that seems to be common in most cases.

Thanks for the help again. Much appreciated.

@aselle

This comment has been minimized.

Copy link
Member

commented Apr 27, 2017

Glad you got it resolved, and thank you for reporting information to help others in the future. Closing for now.

@aselle aselle closed this Apr 27, 2017

@MuhammadHamed

This comment has been minimized.

Copy link

commented May 31, 2017

Hi @quatre008 ... I am having the same error as u had. Which visual studio version did u use ?

@mateon1

This comment has been minimized.

Copy link

commented Jun 10, 2017

Hi, I am having this issue on Linux. I am trying to install tensorflow with pypy.
My ./configure has everything default except the python interpreter /usr/local/bin/pypy.
When importing I get:

Python 2.7.13 (c925e73810367cd960a32592dd7f728f436c125c, Jun 08 2017, 09:20:57)
[PyPy 5.8.0 with GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>> import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/root/nn/pypy2-v5.8.0-src/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/root/nn/pypy2-v5.8.0-src/site-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/root/nn/pypy2-v5.8.0-src/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/root/nn/pypy2-v5.8.0-src/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/root/nn/pypy2-v5.8.0-src/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/root/nn/pypy2-v5.8.0-src/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 20, in swig_import_helper
    import _pywrap_tensorflow_internal
ImportError: No module named _pywrap_tensorflow_internal


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
>>>> 
@flamoedo

This comment has been minimized.

Copy link

commented Jul 28, 2017

Try to use cuDNN v5.1 for CUDA 8.0, this solves the issue for me.

@chriswbarrett

This comment has been minimized.

Copy link

commented Aug 20, 2017

If you are using tensorflow 1.3 then the current documentation, you want to use cuDNN v6.0 #7705

@banyh

This comment has been minimized.

Copy link

commented Aug 23, 2017

  • tensorflow 1.2 + cudnn 5.1: works fine
  • tensorflow 1.2 + cudnn 6.0: ImportError
  • tensorflow 1.3 + cudnn 5.1: works fine
  • tensorflow 1.3 + cudnn 6.0: works fine
@manashmndl

This comment has been minimized.

Copy link

commented Aug 26, 2017

@chriswbarrett Thanks so much!

TensorFlow 1.3 + cudNN 6.0 with Cuda 8 

Working!

@92xianshen

This comment has been minimized.

Copy link

commented Sep 5, 2017

It really does work!

TensorFlow 1.3 + CuDNN 6.0 with Cuda 8

@geilige

This comment has been minimized.

Copy link

commented Sep 6, 2017

TensorFlow 1.3 + CuDNN 6.0与Cuda 8

@soroush361

This comment has been minimized.

Copy link

commented Sep 19, 2017

TensorFlow 1.3 + CuDNN 6.0 with Cuda 8

It worked with CuDNN 6.0. I had "import error" with CuDNN 5.1.

@lintseju

This comment has been minimized.

Copy link

commented Sep 29, 2017

tensorflow 1.3 + cudnn 6.0: works fine
tensorflow 1.3 + cudnn 7.0.2: import error

@Carmezim

This comment has been minimized.

Copy link
Contributor

commented Sep 29, 2017

@lintseju TensorFlow as of now only supports cuDNN v6.0

@Carmezim

This comment has been minimized.

Copy link
Contributor

commented Sep 29, 2017

@aselle should we lock the thread? The solution mostly comes down to reading the
installation docs and is given multiple times in the thread already.

@msatyan

This comment has been minimized.

Copy link

commented Oct 13, 2017

Look like the TensorFlow has stated using cuDNN 6.x in the past couple of days (from 5.1).
(cuDNN=NVIDIA CUDA Deep Neural Network library )
https://www.tensorflow.org/install/install_windows#CommonInstallationProblems
The problem on my computer got solved after I upgrading cuDNN 6.x (TF will not work with cuDNN 7 yet)
https://developer.nvidia.com/cudnn

My configuration is
Windows 10 x64, with GPU GTX 1080 ti
Anaconda 5.0.0 (with Python 3.6)
CUDA Toolkit 8.0
cuDNN v6.0

@user7654

This comment has been minimized.

Copy link

commented Oct 15, 2017

On Win7, W7, Windows 7 try to install Microsoft Visual C++ 2015 Redistributable Update 3
https://www.microsoft.com/en-us/download/details.aspx?id=53587
first. It helped for me.
see: #5949

@tomzx

This comment has been minimized.

Copy link

commented Oct 26, 2017

I have experienced the same issue after replacing hardware on my computer. I tried @mrry script to check the install was correct, and it was (no error reported but import tensorflow would fail). It appears that either my graphics drivers got corrupted or required to be upgraded (I tested by loading up Factorio and the texture would render all wrong).

After installing the 388.00 drivers (http://us.download.nvidia.com/Windows/388.00/388.00-desktop-win8-win7-64bit-international-whql.exe), tensorflow would import again.

@rohit-patel

This comment has been minimized.

Copy link

commented Jan 14, 2018

@sddai

This comment has been minimized.

Copy link

commented Mar 6, 2018

I had the same problem with tensorflow 1.6, i downgrade it to 1.5 and everything is OK now.

pip uninstall tensorflow
And then
pip install tensorflow==1.5

@yslTech

This comment has been minimized.

Copy link

commented Mar 9, 2018

@sddai , I have the same problem, my environment is win7+cuda9.1+cudnn7, I downgrade tensorflow-gpu to 1.5, I still have the same issue

@rohit-patel

This comment has been minimized.

Copy link

commented Mar 9, 2018

@yslTech Cuda 9.1 does not work with tf yet. I've outlined the instructions and troubleshooting in the post above.

@MarioDogan

This comment has been minimized.

Copy link

commented Mar 9, 2018

Please also check if your CPU supports AVX if you have installed tensorflow 1.6. I got this error since my CPU does not support AVX, so I had to downgrade to tensorflow 1.5.

@yslTech

This comment has been minimized.

Copy link

commented Mar 13, 2018

@MarioDogan @rohit-patel I uninstall cuda to 9.0 and I checked my CPU with tool CPU-Z , and found it doesn't support AVX, I downgrade tensorflow-gpu to 1.5 and finally I can import it. Thank you so mach!

@ncmarian

This comment has been minimized.

Copy link

commented Mar 23, 2018

@sddai solution is working !

@curtis-binaryion

This comment has been minimized.

Copy link

commented May 5, 2018

MarioDogan's answer is the one if the PC you're running on is pre-2012, or if you are like "wtf cuda library? I didn't install GPU version."

@stpaulchuck

This comment has been minimized.

Copy link

commented Jul 4, 2018

[non cuda, cpu only version]
this is all about your video chip/card and CPU compatibility with TF VERSION! Current version of Tensor Flow is 1.8 and it crashes on both my machines.

I have a win7 Gateway notebook using an I5 CPU and intel video chip. I have a desktop win7 unit with AMD Phenom II and AMD Radeon HD5450 video card. The I5 notebook requires V1.6 of TensorFlow and the desktop AMD unit takes V1.5. I don't have a GPU available for running ANN's so I don't know how that would affect it.

Here's the command line for PIP install: pip install --upgrade tensorflow==1.5.0 (or whatever other version you need). This will uninstall your current version and then install the indicated version.

Build or copy a small TensorFlow script and run it. Open a second command window and install a different version. I'd recommend starting at 1.5 and working your way up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.