On Windows, running “import tensorflow” generates No module named “_pywrap_tensorflow” error

后端 未结 23 3308
误落风尘
误落风尘 2020-11-22 06:55

On Windows, TensorFlow reports either or both of the following errors after executing an import tensorflow statement:

  • No module named \"_pyw
相关标签:
23条回答
  • 2020-11-22 07:30

    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

    CUDA_HOME = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0"
    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"
    

    You PATHTEXT must include ".DLL" along with other extensions

    ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.DLL"
    

    Also Add the following to you path

    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\extras\CUPTI\libx64;
    C:\Windows\SysWOW64;
    C:\Windows\System32        
    

    If you are getting errors you can download the run the below code by mrry, this code will check your setup and tell you if something is wrong https://gist.github.com/mrry/ee5dbcfdd045fa48a27d56664411d41c

    References : http://blog.nitishmutha.com/tensorflow/2017/01/22/TensorFlow-with-gpu-for-windows.html

    The above reference is very useful. Please comment for improvements to this answer. Hope this helps, Thanks.

    0 讨论(0)
  • 2020-11-22 07:31

    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

    0 讨论(0)
  • 2020-11-22 07:32

    For each Tensorflow's version, it requires different version of CuDnn. On www.tensorflow.org, they did not mentioned about that in installation guide!

    My case use tensorflow version 1.3 which uses cuDNN 6. https://github.com/tensorflow/tensorflow/releases.

    Please check your tensorfow version and cuDNN version if they are match together.

    And please set path environment for cuDNN, if it still does not work, please check the answer from @Chris Han.

    0 讨论(0)
  • 2020-11-22 07:33

    TensorFlow requires MSVCP140.DLL, which may not be installed on your system. To solve it open the terminal en type or paste this link:

    C:\> pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.0.0-cp35-cp35m-win_amd64.whl 
    

    Note this is to install the CPU-only version of TensorFlow.

    0 讨论(0)
  • 2020-11-22 07:33

    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.

    0 讨论(0)
提交回复
热议问题