On Windows, running “import tensorflow” generates

2018-12-31 09:06发布

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.

标签: tensorflow
21条回答
零度萤火
2楼-- · 2018-12-31 09:44

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
查看更多
人间绝色
3楼-- · 2018-12-31 09:44

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.

查看更多
余生无你
4楼-- · 2018-12-31 09:47

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.

查看更多
零度萤火
5楼-- · 2018-12-31 09:49

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.

查看更多
步步皆殇っ
6楼-- · 2018-12-31 09:49

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

查看更多
高级女魔头
7楼-- · 2018-12-31 09:49

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.

查看更多
登录 后发表回答