TensorFlow (GPU) installation in win10+cuda8.0 environment and detailed tutorial of CUDNN package configuration

Source: Internet
Author: User
Installation Environment Win10 Python3.6.4
More than 3.5 version can be, currently tensorflow only support 64-bit python3.5 above version NumPy
After installing Python, open the terminal cmd input PIP3 install NumPy Specific ProcessDownload installation Cuda8.0must be 8.0 version. Download the address and follow the image below to download the local installation package.


If the installation is wrong remember to uninstall the previous removal clean


Configure system environment variable path after Setup completes



TensorFlow is a programming system that uses graphs to represent computational tasks that must be started in session. The session distributes the OP (operation) of the diagram to a device such as a CPU or GPU. So, this time you run Python then import TensorFlow as TF is not going to be an error, but when you're going to execute the TF. The session () may have a problem. This time will call Cuda, and the problem I have encountered here is that various lib,dll cannot load. After a check, navigate to the problem, CUDA installation is completed after the default environment variable configuration is not directly accessible to the bin and lib\x64 under the package, in the path to add these two paths.

Once installed, there will not be more than four environmental variables, and two need to add them themselves.




C:\Program Files\nvidia GPU Computing toolkit\cuda\v8.0
C:\Program Files\nvidia GPU Computing toolkit\cuda\v8.0\bin
C:\Program Files\nvidia GPU Computing toolkit\cuda\v8.0\lib\x64
C:\Program Files\nvidia GPU Computing TOOLKIT\CUDA\V8.0\LIBNVVP



tutorial on configuring environment variables
Finally in CMD input echo%path% will be able to see if you add to the environment variable download Cudnn6.0, download the address, need to register and fill in the questionnaire, download after the compression package, the contents of the folder inside the package copy to the C:\Program Files\nvidia GPU Computing toolkit\cuda\v8.0 inside the three folders.


Finally test and check the code as follows





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


If the failure, remember to check the error message, No installation CUDA8.0 or the environment configuration is not correct:



Could not load ' cudart64_80.dll '. The GPU version of TensorFlow
Requires the this DLL was installed in a directory of that's named in
Your%PATH% environment variable. Download and install CUDA 8.0 from
This Url:https://developer.nvidia.com/cuda-toolkit



Installation success:



TensorFlow successfully installed.
The installed version of the TensorFlow includes GPU support. pay attention to a few Cuba must install version 8.0. Cuba must install version 8.0. Cuba must install version 8.0. Anaconda is not required, you can use a version that can be used without CUDNN I'm here to hint at the CUDNN6, everyone look at the prompts installation follow-up



Run a DQN play Flappybird test:


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.