On Windows, TensorFlow reports either or both of the following errors after executing an import tensorflow
statement:
No module named \"_pyw
After much trial and error, and making sure VC++ 2015 Redistributable, cuDNN DLL and all other dependencies are accessible from PATH, it looks like Tensorflow GPU works only with Python 3.5.2
(as of this writing)
So if you're using Anaconda
conda create -n tensorflow-gpu python=3.5.2
activate tensorflow-gpu
pip install tensorflow-gpu
Then open the python interpreter and verify
>>> import tensorflow as tf
>>> sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
Found device 0 with properties:
name: GeForce 940M
major: 5 minor: 0
memoryClockRate (GHz) 1.176
pciBusID 0000:06:00.0
Total memory: 2.00GiB
Free memory: 1.66GiB
Credits: this neat guide
For the people finding this post in 2019, this error could also occur because the Python version 3.7 does not have support for TensorFlow (see https://www.tensorflow.org/install/pip). So, check the Python version:
python --version
In case it is larger than 3.6, it should be downgraded to 3.6. For Anaconda:
conda install python=3.6
Then, install TensorFlow.
pip install tensorflow
Btw, I did not have the GPU version, so there were no CUDA related issues in my case.
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.
My two cents:
I had a ton of problems trying to get my CUDA 8.0 installed properly on Windows 7. I had a previous version installed and I wanted to upgrade so I uninstalled it and tried to install CUDA 8.0 (for tensorflow 1.3). The installation failed every single time, I tried to downgrade to CUDA 7.5 and was able to install it but had a ton of problems with tensorflow (similar to the PATH problem described here). Long story short: what worked for me was:
1) Uninstall EVERY NVIDIA component (except the display graphics driver)
2) Download CUDA toolkit 8.0 (and the patch) https://developer.nvidia.com/cuda-downloads
3) Check the CheckSum MD5 (I used MS https://www.microsoft.com/en-ca/download/confirmation.aspx?id=11533 but any would do) to make sure they were OK (it happened several times that the installer was not dowloaded properly because my WiFi router apparently).
4) Run the CUDA toolkit installer as root
5) download the cudnn 8.0 v6 and add its location to the PATH variable https://developer.nvidia.com/rdp/cudnn-download
Hope that helps and saves some headaches...
NOTE: This script helped me a lot to debug the problem! (Thank you mrry) https://gist.github.com/mrry/ee5dbcfdd045fa48a27d56664411d41c
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.
The problem for me was the cuDNN library which didn't match the requirements of the graphics card. I downloaded the 6.0 version but for my GTX980ti but the recommended compute capability on the nvidia website was 5.1 ( http://developer.nvidia.com/cuda-gpus ) so I downloaded 5.1 and replaced the 6.0 version and as soon as I've done that it started working.