0

I know people asked this question before. I believe I tried everything written in other StackOverflow questions (On Windows, running "import tensorflow" generates No module named "_pywrap_tensorflow" error). The new TensorFlow 1.7 requires CUDA Toolkit 9.0 and cuDNN v7.0 (both of which I added to my environment path). I also installed the latest version of Visual Studio 17. I reinstalled Python 3.5; Anaconda; CUDA Toolkit 9.0; cuDNN v7.0. Do you think its because of the new VS studio isn't compatible?

This is the error I get:

 import tensorflow as tf
Traceback (most recent call last):
  File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Program Files\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import *  # pylint: disable=redefined-builtin
  File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Program Files\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.
  • I am getting exactly the same error, however I did not use Anaconda (just PIP3), and did not install VS Studio. So I do not think that this a VS Studio incompatability. Sorry for not being able to help more! – Heinz Apr 01 '18 at 05:02
  • I think I figured out why I am facing this problem. The pre-built binaries of Tensorflow 1.6 and greater uses AVX and my computer does not support AVX. If I install TensorFlow 1.5 using pip, I do not face this issue. I will have to try building the binaries of TF 1.7 myself (using Bazel). Hopefully, that will solve my problem. – user3554354 Apr 03 '18 at 00:20

1 Answers1

2

This error might be caused because of generation of your processor. I struggled with the same error for CPU mode only. Checked for 2 machines: win 7 pro, i7 1366 socket and win 7 home with i5 1366 socket with the same output. The problem is that Tensorflow r1.7 seems to require AVX support. Check does your processor support AVX if not switch to Tensor Flow 1.5

For native instalation (python 3.5 or python 3.6)(Tensor Flow r1.5 CPU)

pip3 install tensorflow==1.5

For anaconda (Tensor Flow r1.5 CPU)

conda create -n your_env_name pip python=3.5 (or 3.6)

in next line

activate your_env_name

and finally install Tensorflow 1.5

pip install --ignore-installed tensorflow==1.5

For me two ways work on 2 machines without problems. I have no idea if you are dealing with GPU because I am new and my graphics is not powerfull enough to use.

Enjoy!

  • You are right. It was an AVX issue. I mentioned it in my comments above. Also, you spelled 'tensorflow' incorrectly in your pip commands. Since you have the correct answer, I would recommend to edit it for others to use. – user3554354 Apr 12 '18 at 17:43
  • Thanks for your comment. I fixed spelling and now should be fine. Enjoy! – Marek Sawicki Apr 14 '18 at 06:44