windows下tensorflow安装

1.安装一定要用CUDA8, 安装了半天用CUDA9,结果是搞不了


2.其实anaconda 装tensorflow cpu或者GPU都是超级简单的直接在Navigator 里面配置就行了,网络上的都写的太复杂

3.记得配置环境变量.



配置环境变量的话https://jingyan.baidu.com/article/3ea51489e1c2b752e61bbad0.html

最后在cmd里输入 echo %path%  就能查看你的是否添加进环境变量了


4.帮助文档

[python] view plain copy
print ?
  1. import ctypes  
  2. import imp  
  3. import sys  
  4.   
  5.   
  6. def main():  
  7.     try:  
  8.         import tensorflow as tf  
  9.         print(“TensorFlow successfully installed.”)  
  10.         if tf.test.is_built_with_cuda():  
  11.             print(“The installed version of TensorFlow includes GPU support.”)  
  12.         else:  
  13.             print(“The installed version of TensorFlow does not include GPU support.”)  
  14.         sys.exit(0)  
  15.     except ImportError:  
  16.         print(“ERROR: Failed to import the TensorFlow module.”)  
  17.   
  18.     candidate_explanation = False  
  19.   
  20.     python_version = sys.version_info.major, sys.version_info.minor  
  21.     print(“\n- Python version is %d.%d.” % python_version)  
  22.     if not (python_version == (35or python_version == (36)):  
  23.         candidate_explanation = True  
  24.         print(“- The official distribution of TensorFlow for Windows requires ”  
  25.               ”Python version 3.5 or 3.6.”)  
  26.   
  27.     try:  
  28.         _, pathname, _ = imp.find_module(”tensorflow”)  
  29.         print(“\n- TensorFlow is installed at: %s” % pathname)  
  30.     except ImportError:  
  31.         candidate_explanation = False  
  32.         print(“”“ 
  33. - No module named TensorFlow is installed in this Python environment. You may 
  34.   install it using the command `pip install tensorflow`.”“”)  
  35.   
  36.     try:  
  37.         msvcp140 = ctypes.WinDLL(”msvcp140.dll”)  
  38.     except OSError:  
  39.         candidate_explanation = True  
  40.         print(“”“ 
  41. - Could not load ‘msvcp140.dll’. TensorFlow requires that this DLL be 
  42.   installed in a directory that is named in your %PATH% environment 
  43.   variable. You may install this DLL by downloading Microsoft Visual 
  44.   C++ 2015 Redistributable Update 3 from this URL: 
  45.   https://www.microsoft.com/en-us/download/details.aspx?id=53587”“”)  
  46.   
  47.     try:  
  48.         cudart64_80 = ctypes.WinDLL(”cudart64_80.dll”)  
  49.     except OSError:  
  50.         candidate_explanation = True  
  51.         print(“”“ 
  52. - Could not load ‘cudart64_80.dll’. The GPU version of TensorFlow 
  53.   requires that this DLL be installed in a directory that is named in 
  54.   your %PATH% environment variable. Download and install CUDA 8.0 from 
  55.   this URL: https://developer.nvidia.com/cuda-toolkit”“”)  
  56.   
  57.     try:  
  58.         nvcuda = ctypes.WinDLL(”nvcuda.dll”)  
  59.     except OSError:  
  60.         candidate_explanation = True  
  61.         print(“”“ 
  62. - Could not load ‘nvcuda.dll’. The GPU version of TensorFlow requires that 
  63.   this DLL be installed in a directory that is named in your %PATH% 
  64.   environment variable. Typically it is installed in ‘C:\Windows\System32’. 
  65.   If it is not present, ensure that you have a CUDA-capable GPU with the 
  66.   correct driver installed.”“”)  
  67.   
  68.     cudnn5_found = False  
  69.     try:  
  70.         cudnn5 = ctypes.WinDLL(”cudnn64_5.dll”)  
  71.         cudnn5_found = True  
  72.     except OSError:  
  73.         candidate_explanation = True  
  74.         print(“”“ 
  75. - Could not load ‘cudnn64_5.dll’. The GPU version of TensorFlow 
  76.   requires that this DLL be installed in a directory that is named in 
  77.   your %PATH% environment variable. Note that installing cuDNN is a 
  78.   separate step from installing CUDA, and it is often found in a 
  79.   different directory from the CUDA DLLs. You may install the 
  80.   necessary DLL by downloading cuDNN 5.1 from this URL: 
  81.   https://developer.nvidia.com/cudnn”“”)  
  82.   
  83.     cudnn6_found = False  
  84.     try:  
  85.         cudnn = ctypes.WinDLL(”cudnn64_6.dll”)  
  86.         cudnn6_found = True  
  87.     except OSError:  
  88.         candidate_explanation = True  
  89.   
  90.     if not cudnn5_found or not cudnn6_found:  
  91.         print()  
  92.         if not cudnn5_found and not cudnn6_found:  
  93.             print(“- Could not find cuDNN.”)  
  94.         elif not cudnn5_found:  
  95.             print(“- Could not find cuDNN 5.1.”)  
  96.         else:  
  97.             print(“- Could not find cuDNN 6.”)  
  98.             print(“”“ 
  99.   The GPU version of TensorFlow requires that the correct cuDNN DLL be installed 
  100.   in a directory that is named in your %PATH% environment variable. Note that 
  101.   installing cuDNN is a separate step from installing CUDA, and it is often 
  102.   found in a different directory from the CUDA DLLs. The correct version of 
  103.   cuDNN depends on your version of TensorFlow: 
  104.  
  105.   * TensorFlow 1.2.1 or earlier requires cuDNN 5.1. (‘cudnn64_5.dll’) 
  106.   * TensorFlow 1.3 or later requires cuDNN 6. (‘cudnn64_6.dll’) 
  107.  
  108.   You may install the necessary DLL by downloading cuDNN from this URL: 
  109.   https://developer.nvidia.com/cudnn”“”)  
  110.   
  111.     if not candidate_explanation:  
  112.         print(“”“ 
  113. - All required DLLs appear to be present. Please open an issue on the 
  114.   TensorFlow GitHub page: https://github.com/tensorflow/tensorflow/issues”“”)  
  115.   
  116.     sys.exit(-1)  
  117.   
  118.   
  119. if __name__ == “__main__”:  
  120.     main()  
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.")


    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()


我只是简要的说明了一下,可以先看http://blog.csdn.net/sb19931201/article/details/53648615  如果还不行,再评论问吧

1.安装一定要用CUDA8, 安装了半天用CUDA9,结果是搞不了


2.其实anaconda 装tensorflow cpu或者GPU都是超级简单的直接在Navigator 里面配置就行了,网络上的都写的太复杂

3.记得配置环境变量.



配置环境变量的话https://jingyan.baidu.com/article/3ea51489e1c2b752e61bbad0.html

最后在cmd里输入 echo %path%  就能查看你的是否添加进环境变量了


4.帮助文档

[python] view plain copy
print ?
  1. import ctypes  
  2. import imp  
  3. import sys  
  4.   
  5.   
  6. def main():  
  7.     try:  
  8.         import tensorflow as tf  
  9.         print(“TensorFlow successfully installed.”)  
  10.         if tf.test.is_built_with_cuda():  
  11.             print(“The installed version of TensorFlow includes GPU support.”)  
  12.         else:  
  13.             print(“The installed version of TensorFlow does not include GPU support.”)  
  14.         sys.exit(0)  
  15.     except ImportError:  
  16.         print(“ERROR: Failed to import the TensorFlow module.”)  
  17.   
  18.     candidate_explanation = False  
  19.   
  20.     python_version = sys.version_info.major, sys.version_info.minor  
  21.     print(“\n- Python version is %d.%d.” % python_version)  
  22.     if not (python_version == (35or python_version == (36)):  
  23.         candidate_explanation = True  
  24.         print(“- The official distribution of TensorFlow for Windows requires ”  
  25.               ”Python version 3.5 or 3.6.”)  
  26.   
  27.     try:  
  28.         _, pathname, _ = imp.find_module(”tensorflow”)  
  29.         print(“\n- TensorFlow is installed at: %s” % pathname)  
  30.     except ImportError:  
  31.         candidate_explanation = False  
  32.         print(“”“ 
  33. - No module named TensorFlow is installed in this Python environment. You may 
  34.   install it using the command `pip install tensorflow`.”“”)  
  35.   
  36.     try:  
  37.         msvcp140 = ctypes.WinDLL(”msvcp140.dll”)  
  38.     except OSError:  
  39.         candidate_explanation = True  
  40.         print(“”“ 
  41. - Could not load ‘msvcp140.dll’. TensorFlow requires that this DLL be 
  42.   installed in a directory that is named in your %PATH% environment 
  43.   variable. You may install this DLL by downloading Microsoft Visual 
  44.   C++ 2015 Redistributable Update 3 from this URL: 
  45.   https://www.microsoft.com/en-us/download/details.aspx?id=53587”“”)  
  46.   
  47.     try:  
  48.         cudart64_80 = ctypes.WinDLL(”cudart64_80.dll”)  
  49.     except OSError:  
  50.         candidate_explanation = True  
  51.         print(“”“ 
  52. - Could not load ‘cudart64_80.dll’. The GPU version of TensorFlow 
  53.   requires that this DLL be installed in a directory that is named in 
  54.   your %PATH% environment variable. Download and install CUDA 8.0 from 
  55.   this URL: https://developer.nvidia.com/cuda-toolkit”“”)  
  56.   
  57.     try:  
  58.         nvcuda = ctypes.WinDLL(”nvcuda.dll”)  
  59.     except OSError:  
  60.         candidate_explanation = True  
  61.         print(“”“ 
  62. - Could not load ‘nvcuda.dll’. The GPU version of TensorFlow requires that 
  63.   this DLL be installed in a directory that is named in your %PATH% 
  64.   environment variable. Typically it is installed in ‘C:\Windows\System32’. 
  65.   If it is not present, ensure that you have a CUDA-capable GPU with the 
  66.   correct driver installed.”“”)  
  67.   
  68.     cudnn5_found = False  
  69.     try:  
  70.         cudnn5 = ctypes.WinDLL(”cudnn64_5.dll”)  
  71.         cudnn5_found = True  
  72.     except OSError:  
  73.         candidate_explanation = True  
  74.         print(“”“ 
  75. - Could not load ‘cudnn64_5.dll’. The GPU version of TensorFlow 
  76.   requires that this DLL be installed in a directory that is named in 
  77.   your %PATH% environment variable. Note that installing cuDNN is a 
  78.   separate step from installing CUDA, and it is often found in a 
  79.   different directory from the CUDA DLLs. You may install the 
  80.   necessary DLL by downloading cuDNN 5.1 from this URL: 
  81.   https://developer.nvidia.com/cudnn”“”)  
  82.   
  83.     cudnn6_found = False  
  84.     try:  
  85.         cudnn = ctypes.WinDLL(”cudnn64_6.dll”)  
  86.         cudnn6_found = True  
  87.     except OSError:  
  88.         candidate_explanation = True  
  89.   
  90.     if not cudnn5_found or not cudnn6_found:  
  91.         print()  
  92.         if not cudnn5_found and not cudnn6_found:  
  93.             print(“- Could not find cuDNN.”)  
  94.         elif not cudnn5_found:  
  95.             print(“- Could not find cuDNN 5.1.”)  
  96.         else:  
  97.             print(“- Could not find cuDNN 6.”)  
  98.             print(“”“ 
  99.   The GPU version of TensorFlow requires that the correct cuDNN DLL be installed 
  100.   in a directory that is named in your %PATH% environment variable. Note that 
  101.   installing cuDNN is a separate step from installing CUDA, and it is often 
  102.   found in a different directory from the CUDA DLLs. The correct version of 
  103.   cuDNN depends on your version of TensorFlow: 
  104.  
  105.   * TensorFlow 1.2.1 or earlier requires cuDNN 5.1. (‘cudnn64_5.dll’) 
  106.   * TensorFlow 1.3 or later requires cuDNN 6. (‘cudnn64_6.dll’) 
  107.  
  108.   You may install the necessary DLL by downloading cuDNN from this URL: 
  109.   https://developer.nvidia.com/cudnn”“”)  
  110.   
  111.     if not candidate_explanation:  
  112.         print(“”“ 
  113. - All required DLLs appear to be present. Please open an issue on the 
  114.   TensorFlow GitHub page: https://github.com/tensorflow/tensorflow/issues”“”)  
  115.   
  116.     sys.exit(-1)  
  117.   
  118.   
  119. if __name__ == “__main__”:  
  120.     main()  
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.")


    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()


我只是简要的说明了一下,可以先看http://blog.csdn.net/sb19931201/article/details/53648615  如果还不行,再评论问吧

猜你喜欢

转载自blog.csdn.net/qq_34562093/article/details/79084915