Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[DEPRECATED] TensorFlow on Windows self-check
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""A script for testing that TensorFlow is installed correctly on Windows.
The script will attempt to verify your TensorFlow installation, and print
suggestions for how to fix your installation.
"""
import ctypes
import imp
import sys
def main():
try:
import tensorflow as tf
print("TensorFlow successfully installed.")
if tf.test.is_built_with_cuda():
print("The installed version of TensorFlow includes GPU support.")
else:
print("The installed version of TensorFlow does not include GPU support.")
sys.exit(0)
except ImportError:
print("ERROR: Failed to import the TensorFlow module.")
print("""
WARNING! This script is no longer maintained!
=============================================
Since TensorFlow 1.4, the self-check has been integrated with TensorFlow itself,
and any missing DLLs will be reported when you execute the `import tensorflow`
statement. The error messages printed below refer to TensorFlow 1.3 and earlier,
and are inaccurate for later versions of TensorFlow.""")
candidate_explanation = False
python_version = sys.version_info.major, sys.version_info.minor
print("\n- Python version is %d.%d." % python_version)
if not (python_version == (3, 5) or python_version == (3, 6)):
candidate_explanation = True
print("- The official distribution of TensorFlow for Windows requires "
"Python version 3.5 or 3.6.")
try:
_, pathname, _ = imp.find_module("tensorflow")
print("\n- TensorFlow is installed at: %s" % pathname)
except ImportError:
candidate_explanation = False
print("""
- No module named TensorFlow is installed in this Python environment. You may
install it using the command `pip install tensorflow`.""")
try:
msvcp140 = ctypes.WinDLL("msvcp140.dll")
except OSError:
candidate_explanation = True
print("""
- Could not load 'msvcp140.dll'. TensorFlow requires that this DLL be
installed in a directory that is named in your %PATH% environment
variable. You may install this DLL by downloading Microsoft Visual
C++ 2015 Redistributable Update 3 from this URL:
https://www.microsoft.com/en-us/download/details.aspx?id=53587""")
try:
cudart64_80 = ctypes.WinDLL("cudart64_80.dll")
except OSError:
candidate_explanation = True
print("""
- Could not load 'cudart64_80.dll'. The GPU version of TensorFlow
requires that this DLL be installed in a directory that is named in
your %PATH% environment variable. Download and install CUDA 8.0 from
this URL: https://developer.nvidia.com/cuda-toolkit""")
try:
nvcuda = ctypes.WinDLL("nvcuda.dll")
except OSError:
candidate_explanation = True
print("""
- Could not load 'nvcuda.dll'. The GPU version of TensorFlow requires that
this DLL be installed in a directory that is named in your %PATH%
environment variable. Typically it is installed in 'C:\Windows\System32'.
If it is not present, ensure that you have a CUDA-capable GPU with the
correct driver installed.""")
cudnn5_found = False
try:
cudnn5 = ctypes.WinDLL("cudnn64_5.dll")
cudnn5_found = True
except OSError:
candidate_explanation = True
print("""
- Could not load 'cudnn64_5.dll'. The GPU version of TensorFlow
requires that this DLL be installed in a directory that is named in
your %PATH% environment variable. Note that installing cuDNN is a
separate step from installing CUDA, and it is often found in a
different directory from the CUDA DLLs. You may install the
necessary DLL by downloading cuDNN 5.1 from this URL:
https://developer.nvidia.com/cudnn""")
cudnn6_found = False
try:
cudnn = ctypes.WinDLL("cudnn64_6.dll")
cudnn6_found = True
except OSError:
candidate_explanation = True
if not cudnn5_found or not cudnn6_found:
print()
if not cudnn5_found and not cudnn6_found:
print("- Could not find cuDNN.")
elif not cudnn5_found:
print("- Could not find cuDNN 5.1.")
else:
print("- Could not find cuDNN 6.")
print("""
The GPU version of TensorFlow requires that the correct cuDNN DLL be installed
in a directory that is named in your %PATH% environment variable. Note that
installing cuDNN is a separate step from installing CUDA, and it is often
found in a different directory from the CUDA DLLs. The correct version of
cuDNN depends on your version of TensorFlow:
* TensorFlow 1.2.1 or earlier requires cuDNN 5.1. ('cudnn64_5.dll')
* TensorFlow 1.3 or later requires cuDNN 6. ('cudnn64_6.dll')
You may install the necessary DLL by downloading cuDNN from this URL:
https://developer.nvidia.com/cudnn""")
if not candidate_explanation:
print("""
- All required DLLs appear to be present. Please open an issue on the
TensorFlow GitHub page: https://github.com/tensorflow/tensorflow/issues""")
sys.exit(-1)
if __name__ == "__main__":
main()
@sameertikoo

This comment has been minimized.

Show comment
Hide comment
@sameertikoo

sameertikoo Jun 25, 2017

Thanks a lot dude.
I was trying to troubleshoot tensorflow-gpu install with cuda on windows 10 for weeks!!!
This really helped me!
Thanks again !

Thanks a lot dude.
I was trying to troubleshoot tensorflow-gpu install with cuda on windows 10 for weeks!!!
This really helped me!
Thanks again !

@ManojPabani

This comment has been minimized.

Show comment
Hide comment
@ManojPabani

ManojPabani Jun 29, 2017

I am getting these error how can i fix them?

C:\PythonPrograms>python tensorflow_self_check.py
ERROR: Failed to import the TensorFlow module.

  • Python version is 3.5.

  • TensorFlow is installed at: C:\Users\Manoj\AppData\Local\Programs\Python\Pytho
    n35\lib\site-packages\tensorflow

  • Could not load 'msvcp140.dll'. TensorFlow requires that this DLL be
    installed in a directory that is named in your %PATH% environment
    variable. You may install this DLL by downloading Microsoft Visual
    C++ 2015 Redistributable Update 3 from this URL:
    https://www.microsoft.com/en-us/download/details.aspx?id=53587

  • Could not load 'cudart64_80.dll'. The GPU version of TensorFlow
    requires that this DLL be installed in a directory that is named in
    your %PATH% environment variable. Download and install CUDA 8.0 from
    this URL: https://developer.nvidia.com/cuda-toolkit

  • Could not load 'nvcuda.dll'. The GPU version of TensorFlow requires that
    this DLL be installed in a directory that is named in your %PATH%
    environment variable. Typically it is installed in 'C:\Windows\System32'.
    If it is not present, ensure that you have a CUDA-capable GPU with the
    correct driver installed.

  • Could not load 'cudnn64_5.dll'. The GPU version of TensorFlow
    requires that this DLL be installed in a directory that is named in
    your %PATH% environment variable. Note that installing cuDNN is a
    separate step from installing CUDA, and it is often found in a
    different directory from the CUDA DLLs. You may install the
    necessary DLL by downloading cuDNN 5.1 from this URL:
    https://developer.nvidia.com/cudnn

I found the 'msvcp140.dll' in C drive and i pasted in python folder which is mention in path variable but still it gives me the same error.

ManojPabani commented Jun 29, 2017

I am getting these error how can i fix them?

C:\PythonPrograms>python tensorflow_self_check.py
ERROR: Failed to import the TensorFlow module.

  • Python version is 3.5.

  • TensorFlow is installed at: C:\Users\Manoj\AppData\Local\Programs\Python\Pytho
    n35\lib\site-packages\tensorflow

  • Could not load 'msvcp140.dll'. TensorFlow requires that this DLL be
    installed in a directory that is named in your %PATH% environment
    variable. You may install this DLL by downloading Microsoft Visual
    C++ 2015 Redistributable Update 3 from this URL:
    https://www.microsoft.com/en-us/download/details.aspx?id=53587

  • Could not load 'cudart64_80.dll'. The GPU version of TensorFlow
    requires that this DLL be installed in a directory that is named in
    your %PATH% environment variable. Download and install CUDA 8.0 from
    this URL: https://developer.nvidia.com/cuda-toolkit

  • Could not load 'nvcuda.dll'. The GPU version of TensorFlow requires that
    this DLL be installed in a directory that is named in your %PATH%
    environment variable. Typically it is installed in 'C:\Windows\System32'.
    If it is not present, ensure that you have a CUDA-capable GPU with the
    correct driver installed.

  • Could not load 'cudnn64_5.dll'. The GPU version of TensorFlow
    requires that this DLL be installed in a directory that is named in
    your %PATH% environment variable. Note that installing cuDNN is a
    separate step from installing CUDA, and it is often found in a
    different directory from the CUDA DLLs. You may install the
    necessary DLL by downloading cuDNN 5.1 from this URL:
    https://developer.nvidia.com/cudnn

I found the 'msvcp140.dll' in C drive and i pasted in python folder which is mention in path variable but still it gives me the same error.

@rogerguess

This comment has been minimized.

Show comment
Hide comment
@rogerguess

rogerguess Jul 3, 2017

Thank you for this.

Thank you for this.

@justprotato

This comment has been minimized.

Show comment
Hide comment
@justprotato

justprotato Jul 20, 2017

Hello,@mrry.
After using your script, I got

ERROR: Failed to import the TensorFlow module.


I m trying Python 3.5.3 Tensorflow GPU version nightly binaries(#243), but I got similar error output as #8161

However, I can import the tensorflow successfully if I use the below version:
pip install --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.0-cp35-cp35m-win_amd64.whl

Really need your help.
Thank you for helping me.

justprotato commented Jul 20, 2017

Hello,@mrry.
After using your script, I got

ERROR: Failed to import the TensorFlow module.


I m trying Python 3.5.3 Tensorflow GPU version nightly binaries(#243), but I got similar error output as #8161

However, I can import the tensorflow successfully if I use the below version:
pip install --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.0-cp35-cp35m-win_amd64.whl

Really need your help.
Thank you for helping me.

@jubjamie

This comment has been minimized.

Show comment
Hide comment
@jubjamie

jubjamie Jul 20, 2017

@justprotato Pop this on Stack Overflow and I can probably help. I've been having these issues and think that I know what the issue is. Don't want to spam here though.

@justprotato Pop this on Stack Overflow and I can probably help. I've been having these issues and think that I know what the issue is. Don't want to spam here though.

@justprotato

This comment has been minimized.

Show comment
Hide comment
@justprotato

justprotato Jul 21, 2017

Thank you, @jubjamie. I have posted in Stack Overflow

Thank you, @jubjamie. I have posted in Stack Overflow

@monomon

This comment has been minimized.

Show comment
Hide comment
@monomon

monomon Jul 24, 2017

That's a great script!
There is a spurious ")" on line 111, so syntax error.

monomon commented Jul 24, 2017

That's a great script!
There is a spurious ")" on line 111, so syntax error.

@glenlewis

This comment has been minimized.

Show comment
Hide comment
@glenlewis

glenlewis Jul 26, 2017

Brilliant Script.
Peeps will need to remove
if not cudnn5_found and not cudnn6_found):
and replace with
if not cudnn5_found and not cudnn6_found:

Brilliant Script.
Peeps will need to remove
if not cudnn5_found and not cudnn6_found):
and replace with
if not cudnn5_found and not cudnn6_found:

@fierval

This comment has been minimized.

Show comment
Hide comment
@fierval

fierval Jul 28, 2017

Thank you very much! Brilliant.

fierval commented Jul 28, 2017

Thank you very much! Brilliant.

@karenerobinson

This comment has been minimized.

Show comment
Hide comment
@karenerobinson

karenerobinson Jul 31, 2017

thank you glenlewis for pointing out the syntax error

thank you glenlewis for pointing out the syntax error

@RobinBaumann

This comment has been minimized.

Show comment
Hide comment
@RobinBaumann

RobinBaumann Aug 2, 2017

When running the script I get no output. When running it in PyCharm it says: "Process finished with exit code 0" but none of the print statements gets printed. Same when executing the script in cmd.

When running the script I get no output. When running it in PyCharm it says: "Process finished with exit code 0" but none of the print statements gets printed. Same when executing the script in cmd.

@areel

This comment has been minimized.

Show comment
Hide comment
@areel

areel Aug 17, 2017

Thank you for supplying this. I would never have found out that

  • TensorFlow 1.3 or later requires cuDNN 6. ('cudnn64_6.dll')

Because unfortunately as of today (17th Aug 2017) https://www.tensorflow.org/install/install_windows was stating cuDNN v5.1 was required.

I know you have saved me hours.

areel commented Aug 17, 2017

Thank you for supplying this. I would never have found out that

  • TensorFlow 1.3 or later requires cuDNN 6. ('cudnn64_6.dll')

Because unfortunately as of today (17th Aug 2017) https://www.tensorflow.org/install/install_windows was stating cuDNN v5.1 was required.

I know you have saved me hours.

@limingwu8

This comment has been minimized.

Show comment
Hide comment
@limingwu8

limingwu8 Aug 18, 2017

Thank you so much! The official website of tensorflow is misleading, it says I need cuDNN5.1. After I run your test program, it says I need cuDNN6.0, then I fixed it! Thank you!

Thank you so much! The official website of tensorflow is misleading, it says I need cuDNN5.1. After I run your test program, it says I need cuDNN6.0, then I fixed it! Thank you!

@prdas31

This comment has been minimized.

Show comment
Hide comment
@prdas31

prdas31 Aug 18, 2017

Okay. Solved it. Same issue as TensorFlow 1.3 or later requires cuDNN 6. ('cudnn64_6.dll')

prdas31 commented Aug 18, 2017

Okay. Solved it. Same issue as TensorFlow 1.3 or later requires cuDNN 6. ('cudnn64_6.dll')

@Jumabek

This comment has been minimized.

Show comment
Hide comment
@Jumabek

Jumabek Aug 21, 2017

@prdas31 thanks for sharing, you saved the day!

Jumabek commented Aug 21, 2017

@prdas31 thanks for sharing, you saved the day!

@yyq263

This comment has been minimized.

Show comment
Hide comment
@yyq263

yyq263 Aug 22, 2017

It solves my problem not loading DLL after I switch cuDNN5.1 to cuDNN6.0. Thanks a lot!

yyq263 commented Aug 22, 2017

It solves my problem not loading DLL after I switch cuDNN5.1 to cuDNN6.0. Thanks a lot!

@jasonyoun

This comment has been minimized.

Show comment
Hide comment
@jasonyoun

jasonyoun Aug 23, 2017

This really saved me. The install guide https://www.tensorflow.org/install/install_windows explicitly mentioned cuDNN v5.1. So I was really stuck until I ran this code. cuDNN v6.0 was all I needed.

This really saved me. The install guide https://www.tensorflow.org/install/install_windows explicitly mentioned cuDNN v5.1. So I was really stuck until I ran this code. cuDNN v6.0 was all I needed.

@lyf5

This comment has been minimized.

Show comment
Hide comment
@lyf5

lyf5 Aug 23, 2017

Thank you very much! This problem has already spend my two days.

When the tensorflow version is 1.3, you must download cuDNN6!! But in the mainpage of tensorflow, It appears cuDNN5 still.

lyf5 commented Aug 23, 2017

Thank you very much! This problem has already spend my two days.

When the tensorflow version is 1.3, you must download cuDNN6!! But in the mainpage of tensorflow, It appears cuDNN5 still.

@nikkou

This comment has been minimized.

Show comment
Hide comment
@nikkou

nikkou Aug 28, 2017

This is superb, I had no idea I had to downgrade cuDNN from 7 to 6 before I ran this script.

nikkou commented Aug 28, 2017

This is superb, I had no idea I had to downgrade cuDNN from 7 to 6 before I ran this script.

@vcvycy

This comment has been minimized.

Show comment
Hide comment
@vcvycy

vcvycy Aug 29, 2017

I spend all day fixing the "dll loaded failed" problem...And finally,resolve it according to This Script...HAHAHAH...

vcvycy commented Aug 29, 2017

I spend all day fixing the "dll loaded failed" problem...And finally,resolve it according to This Script...HAHAHAH...

@JorleyOliveira

This comment has been minimized.

Show comment
Hide comment
@JorleyOliveira

JorleyOliveira Sep 3, 2017

Muito obrigado pelo script.

Muito obrigado pelo script.

@patrickspry

This comment has been minimized.

Show comment
Hide comment
@patrickspry

patrickspry Sep 4, 2017

Super helpful - thanks a ton!

Super helpful - thanks a ton!

@XiaoruiZhu

This comment has been minimized.

Show comment
Hide comment
@XiaoruiZhu

XiaoruiZhu Sep 13, 2017

Really great function. It is super helpful.

Really great function. It is super helpful.

@edgarbc

This comment has been minimized.

Show comment
Hide comment
@edgarbc

edgarbc Sep 13, 2017

Thanks a lot! it is of great help

edgarbc commented Sep 13, 2017

Thanks a lot! it is of great help

@heisenbugfix

This comment has been minimized.

Show comment
Hide comment
@heisenbugfix

heisenbugfix Sep 15, 2017

Thanks a lot. Saved a lot of time

Thanks a lot. Saved a lot of time

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Sep 19, 2017

Thank you very much!

ghost commented Sep 19, 2017

Thank you very much!

@diarabit

This comment has been minimized.

Show comment
Hide comment
@diarabit

diarabit Sep 21, 2017

It is really helpful to me.
Thank u so much.

It is really helpful to me.
Thank u so much.

@ajithor

This comment has been minimized.

Show comment
Hide comment
@ajithor

ajithor Sep 24, 2017

Couldn't really run that code..it spat some error pointing to main..
But the code..really efficient..helped me figure out what was wrong..You got me out of a loophole that I've been stuck since the last 2 days..
Thank you :)

ajithor commented Sep 24, 2017

Couldn't really run that code..it spat some error pointing to main..
But the code..really efficient..helped me figure out what was wrong..You got me out of a loophole that I've been stuck since the last 2 days..
Thank you :)

@idjhuang

This comment has been minimized.

Show comment
Hide comment
@idjhuang

idjhuang Sep 29, 2017

Google should include this check into TensorFlow utility. Good job!

Google should include this check into TensorFlow utility. Good job!

@devilsnare007

This comment has been minimized.

Show comment
Hide comment
@devilsnare007

devilsnare007 Oct 7, 2017

Man i dont get what Im doing wrong here... this script runs then quickly closes! :/
Update: Got the script to work, it appears its not for TF 1.3, Cuda v9.0, cudnn7.0 (tried on Win 10 x64 using Anaconda).... or maybe I am just a noob!

devilsnare007 commented Oct 7, 2017

Man i dont get what Im doing wrong here... this script runs then quickly closes! :/
Update: Got the script to work, it appears its not for TF 1.3, Cuda v9.0, cudnn7.0 (tried on Win 10 x64 using Anaconda).... or maybe I am just a noob!

@kaaztech

This comment has been minimized.

Show comment
Hide comment
@kaaztech

kaaztech Oct 8, 2017

There was an error and it was very troubled.
The cause was understood by this script and it was solved.

Thank you.

kaaztech commented Oct 8, 2017

There was an error and it was very troubled.
The cause was understood by this script and it was solved.

Thank you.

@jcrousse

This comment has been minimized.

Show comment
Hide comment
@jcrousse

jcrousse Oct 8, 2017

Hi, thanks a lot for this script.
I'm a bit surprised to see that "cudart64_80.dll" is missing. I used the same CUDA 8.0 installer as I used a month ago when I have been able to get tensorflow to work on my windows machine with GPU.
I also tried a newer versions of the CUDA toolkit (8.1), but I never get a "cudart64_80.dll" library after the installation.
Any idea why I do not have it?

jcrousse commented Oct 8, 2017

Hi, thanks a lot for this script.
I'm a bit surprised to see that "cudart64_80.dll" is missing. I used the same CUDA 8.0 installer as I used a month ago when I have been able to get tensorflow to work on my windows machine with GPU.
I also tried a newer versions of the CUDA toolkit (8.1), but I never get a "cudart64_80.dll" library after the installation.
Any idea why I do not have it?

@smatmo

This comment has been minimized.

Show comment
Hide comment
@smatmo

smatmo Oct 15, 2017

Thanks a lot! It would be great if the TF people would link to this script from their installation site -- would save some trouble.

smatmo commented Oct 15, 2017

Thanks a lot! It would be great if the TF people would link to this script from their installation site -- would save some trouble.

@WINGHARE

This comment has been minimized.

Show comment
Hide comment
@WINGHARE

WINGHARE Oct 18, 2017

Thanks a lot! It helps me to check my installation

Thanks a lot! It helps me to check my installation

@dikshantx

This comment has been minimized.

Show comment
Hide comment
@dikshantx

dikshantx Oct 18, 2017

Am not able to figure out whats wrong please help :/

#############################################################
ERROR: Failed to import the TensorFlow module.

  • Python version is 3.5.

  • TensorFlow is installed at: /usr/local/lib/python3.5/dist-packages/tensorflow
    Traceback (most recent call last):
    File "tensorflow_self_check.py", line 138, in
    main()
    File "tensorflow_self_check.py", line 56, in main
    msvcp140 = ctypes.WinDLL("msvcp140.dll")
    AttributeError: module 'ctypes' has no attribute 'WinDLL'

Am not able to figure out whats wrong please help :/

#############################################################
ERROR: Failed to import the TensorFlow module.

  • Python version is 3.5.

  • TensorFlow is installed at: /usr/local/lib/python3.5/dist-packages/tensorflow
    Traceback (most recent call last):
    File "tensorflow_self_check.py", line 138, in
    main()
    File "tensorflow_self_check.py", line 56, in main
    msvcp140 = ctypes.WinDLL("msvcp140.dll")
    AttributeError: module 'ctypes' has no attribute 'WinDLL'

@mrry

This comment has been minimized.

Show comment
Hide comment
@mrry

mrry Oct 23, 2017

@dikshantx It looks like you're not running on Windows. This script is only intended for dealing with Windows installation issues.

Owner

mrry commented Oct 23, 2017

@dikshantx It looks like you're not running on Windows. This script is only intended for dealing with Windows installation issues.

@Deepak5j

This comment has been minimized.

Show comment
Hide comment

👍

@ShixiangWan

This comment has been minimized.

Show comment
Hide comment
@ShixiangWan

ShixiangWan Nov 8, 2017

Wow! So amazing! Thank you very much!

Wow! So amazing! Thank you very much!

@elyfialkoff

This comment has been minimized.

Show comment
Hide comment
@elyfialkoff

elyfialkoff Dec 4, 2017

Says its all good, I had to download a few of the cudnn version files until I finally got the correct one.

Says its all good, I had to download a few of the cudnn version files until I finally got the correct one.

@vylia

This comment has been minimized.

Show comment
Hide comment
@vylia

vylia Jan 12, 2018

Thank you, it seems very useful. I'm already applying the recommendations and waiting for tensorflow to work in my system.

vylia commented Jan 12, 2018

Thank you, it seems very useful. I'm already applying the recommendations and waiting for tensorflow to work in my system.

@jxyzzy

This comment has been minimized.

Show comment
Hide comment
@jxyzzy

jxyzzy Feb 2, 2018

please note that tensorflow now seems to require cuda 9.0 and not 8.0 as required in your script.

after uninstalling/reinstalling 8.0 to get your script working (which I appreciate the hardwork), I added the first import line from here:
https://www.tensorflow.org/install/install_windows#validate_your_installation
...and received this error:
ImportError: Could not find 'cudart64_90.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 9.0 from this URL: https://developer.nvidia.com/cuda-toolkit

...once you fix this updated requirement in the script, be sure to update the cuDNN file too. if not, you'll receive the following error:
ImportError: Could not find 'cudnn64_7.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Note that installing cuDNN is a separate step from installing CUDA, and this DLL is often found in a different directory from the CUDA DLLs. You may install the necessary DLL by downloading cuDNN 7 from this URL: https://developer.nvidia.com/cudnn

after you retrieve and install... it finally seems to work:
'Hello, TensorFlow!'

jxyzzy commented Feb 2, 2018

please note that tensorflow now seems to require cuda 9.0 and not 8.0 as required in your script.

after uninstalling/reinstalling 8.0 to get your script working (which I appreciate the hardwork), I added the first import line from here:
https://www.tensorflow.org/install/install_windows#validate_your_installation
...and received this error:
ImportError: Could not find 'cudart64_90.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 9.0 from this URL: https://developer.nvidia.com/cuda-toolkit

...once you fix this updated requirement in the script, be sure to update the cuDNN file too. if not, you'll receive the following error:
ImportError: Could not find 'cudnn64_7.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Note that installing cuDNN is a separate step from installing CUDA, and this DLL is often found in a different directory from the CUDA DLLs. You may install the necessary DLL by downloading cuDNN 7 from this URL: https://developer.nvidia.com/cudnn

after you retrieve and install... it finally seems to work:
'Hello, TensorFlow!'

@jxyzzy

This comment has been minimized.

Show comment
Hide comment
@jxyzzy

jxyzzy Feb 2, 2018

again, very helpful script; awesome work.
brief recap from my comment above... as of today 2018-02-02, requirements are:

  1. Microsoft Visual C++ 2015 Redistributable Update 3 (thank you script): https://www.microsoft.com/en-us/download/details.aspx?id=53587
  2. CUDA 9.0 (no longer 8.0 as in the script): https://developer.nvidia.com/cuda-90-download-archive
  3. Download cuDNN v7.0.5 (Dec 5, 2017), for CUDA 9.0 (its no longer 5.1 as in the script): https://developer.nvidia.com/rdp/cudnn-download
  4. might as well throw this in too... in order to clone to run next step:
    https://www.tensorflow.org/get_started/premade_estimators#getting_the_sample_code
    you'll need git:
    https://github.com/git-for-windows/git/releases
    (took me a few minutes to find it)

Good Luck!
Prediction is "Sentosa" (99.5%), expected "Setosa"

Prediction is "Versicolor" (97.0%), expected "Versicolor"

Prediction is "Virginica" (97.8%), expected "Virginica"

jxyzzy commented Feb 2, 2018

again, very helpful script; awesome work.
brief recap from my comment above... as of today 2018-02-02, requirements are:

  1. Microsoft Visual C++ 2015 Redistributable Update 3 (thank you script): https://www.microsoft.com/en-us/download/details.aspx?id=53587
  2. CUDA 9.0 (no longer 8.0 as in the script): https://developer.nvidia.com/cuda-90-download-archive
  3. Download cuDNN v7.0.5 (Dec 5, 2017), for CUDA 9.0 (its no longer 5.1 as in the script): https://developer.nvidia.com/rdp/cudnn-download
  4. might as well throw this in too... in order to clone to run next step:
    https://www.tensorflow.org/get_started/premade_estimators#getting_the_sample_code
    you'll need git:
    https://github.com/git-for-windows/git/releases
    (took me a few minutes to find it)

Good Luck!
Prediction is "Sentosa" (99.5%), expected "Setosa"

Prediction is "Versicolor" (97.0%), expected "Versicolor"

Prediction is "Virginica" (97.8%), expected "Virginica"

@jlsm

This comment has been minimized.

Show comment
Hide comment
@jlsm

jlsm Feb 25, 2018

Thank you! You saved my day.

jlsm commented Feb 25, 2018

Thank you! You saved my day.

@thuojb

This comment has been minimized.

Show comment
Hide comment
@thuojb

thuojb Mar 3, 2018

I've recently installed windows 10. I then installed python 3.5.2 and Tensorflow 1.6 but when I run the test script i get this error;

C:\Users\Don>python
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [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\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\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 906, in create_module
File "", line 222, in _call_with_frames_removed
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 "C:\Users\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('pywrap_tensorflow_internal')
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\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\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow_init_.py", line 24, in
from tensorflow.python import *
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python_init_.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\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 906, in create_module
File "", line 222, in _call_with_frames_removed
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 "C:\Users\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('pywrap_tensorflow_internal')
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\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_problems

for some common reasons and solutions. Include the entire stack trace

ot this. Kindly help

C:\Users\Don>python tensorflow_self_check.py
ERROR: Failed to import the TensorFlow module.

Python version is 3.5.

TensorFlow is installed at: C:\Users\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow

Could not load 'cudart64_80.dll'. The GPU version of TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 8.0 from this URL: https://developer.nvidia.com/cuda-toolkit

Could not load 'nvcuda.dll'. The GPU version of TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Typically it is installed in 'C:\Windows\System32'. If it is not present, ensure that you have a CUDA-capable GPU with the correct driver installed.

Could not load 'cudnn64_5.dll'. The GPU version of TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Note that installing cuDNN is a separate step from installing CUDA, and it is often found in a different directory from the CUDA DLLs. You may install the necessary DLL by downloading cuDNN 5.1 from this URL: https://developer.nvidia.com/cudnn

Could not find cuDNN.

C:\Users\Don>

I don't understand this as I'm using CPU version

thuojb commented Mar 3, 2018

I've recently installed windows 10. I then installed python 3.5.2 and Tensorflow 1.6 but when I run the test script i get this error;

C:\Users\Don>python
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [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\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\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 906, in create_module
File "", line 222, in _call_with_frames_removed
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 "C:\Users\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('pywrap_tensorflow_internal')
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\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\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow_init_.py", line 24, in
from tensorflow.python import *
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python_init_.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\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 906, in create_module
File "", line 222, in _call_with_frames_removed
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 "C:\Users\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('pywrap_tensorflow_internal')
File "C:\Users\Don\AppData\Local\Programs\Python\Python35\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_problems

for some common reasons and solutions. Include the entire stack trace

ot this. Kindly help

C:\Users\Don>python tensorflow_self_check.py
ERROR: Failed to import the TensorFlow module.

Python version is 3.5.

TensorFlow is installed at: C:\Users\Don\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow

Could not load 'cudart64_80.dll'. The GPU version of TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 8.0 from this URL: https://developer.nvidia.com/cuda-toolkit

Could not load 'nvcuda.dll'. The GPU version of TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Typically it is installed in 'C:\Windows\System32'. If it is not present, ensure that you have a CUDA-capable GPU with the correct driver installed.

Could not load 'cudnn64_5.dll'. The GPU version of TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Note that installing cuDNN is a separate step from installing CUDA, and it is often found in a different directory from the CUDA DLLs. You may install the necessary DLL by downloading cuDNN 5.1 from this URL: https://developer.nvidia.com/cudnn

Could not find cuDNN.

C:\Users\Don>

I don't understand this as I'm using CPU version

@thuojb

This comment has been minimized.

Show comment
Hide comment
@thuojb

thuojb Mar 3, 2018

Seems tensorflow 1.6 is the issue,
I've downgraded to 1.5 and it works just fine

thuojb commented Mar 3, 2018

Seems tensorflow 1.6 is the issue,
I've downgraded to 1.5 and it works just fine

@mrry

This comment has been minimized.

Show comment
Hide comment
@mrry

mrry Mar 5, 2018

Just a note to anybody who is still using this script: since TF 1.4, the checks have been integrated into TensorFlow when you import tensorflow, and this script is no longer maintained. In particular, TF 1.5 and 1.6 require a newer version of CUDA (9.0) and cuDNN (7.0), and you may need to upgrade your CUDA/cuDNN installation to get these.

Owner

mrry commented Mar 5, 2018

Just a note to anybody who is still using this script: since TF 1.4, the checks have been integrated into TensorFlow when you import tensorflow, and this script is no longer maintained. In particular, TF 1.5 and 1.6 require a newer version of CUDA (9.0) and cuDNN (7.0), and you may need to upgrade your CUDA/cuDNN installation to get these.

@djsam113

This comment has been minimized.

Show comment
Hide comment
@djsam113

djsam113 Mar 7, 2018

I'm getting installation errors for tensorflow CPU version, will this help me to troubleshoot the problems.

djsam113 commented Mar 7, 2018

I'm getting installation errors for tensorflow CPU version, will this help me to troubleshoot the problems.

@pyparam

This comment has been minimized.

Show comment
Hide comment
@pyparam

pyparam Apr 6, 2018

this script is asking for graphics files while I am using CPU version only

pyparam commented Apr 6, 2018

this script is asking for graphics files while I am using CPU version only

@pyparam

This comment has been minimized.

Show comment
Hide comment
@pyparam

pyparam Apr 6, 2018

It seems there is the problem with the newer windows CPU version (1.6 onwards ) of tensorflow.
I installed 1.5 it works fine in windows
pip install tensorflow==1.5

pyparam commented Apr 6, 2018

It seems there is the problem with the newer windows CPU version (1.6 onwards ) of tensorflow.
I installed 1.5 it works fine in windows
pip install tensorflow==1.5

@ialhashim

This comment has been minimized.

Show comment
Hide comment
@ialhashim

ialhashim May 8, 2018

I faced a similar problem using a Paperspace Windows 10 virtual machine. Reverting to tensorflow 1.5 helped.

ialhashim commented May 8, 2018

I faced a similar problem using a Paperspace Windows 10 virtual machine. Reverting to tensorflow 1.5 helped.

@abbaskhan857

This comment has been minimized.

Show comment
Hide comment
@abbaskhan857

abbaskhan857 Jun 21, 2018

thanks pyparam!! i downgrade the tensorflow versions from 1.8 to 1.5 and it worked for me.

thanks pyparam!! i downgrade the tensorflow versions from 1.8 to 1.5 and it worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment