Install and Run TensorFlow and Keras on GPU using Anaconda Navigator | iNNovationMerge

Install and Run TensorFlow and Keras on GPU using Anaconda Navigator



For Feedbacks | Enquiries | Questions | Comments - Contact us @ innovationmerge@gmail.com


What?

  • This article explains how to setup TensorFlow and Keras deep learning frameworks with GPU for computation on windows 10 machine with NVIDIA GEFORCE 940MX GPU.

Why?

  • Deep learning has taken Artificial Intelligence into the next level by building intelligent machines and systems.
  • The mostly used frameworks in Deep learning is Tensorflow and Keras. Sometimes installation of these frameworks will take lot of Developers time.
  • This article focuses on providing steps to install these and save Developer time.

How?

Software’s Required:

Network Requirements

  • Internet to download packages

Implementation

Open Anaconda Navigator

  • Open Anaconda Navigator (Source: iNNovationMerge)

Open Environments Tab

  • Click on Create
  • Create Environment (Source: iNNovationMerge)

Create new environment

  • Enter environment name (Ex: neural_tf)
  • Select Python and version as 3.7
  • Click on create
  • Python selection (Source: iNNovationMerge)

Add conda-forge URL to Channels

  • Add Channels (Source: iNNovationMerge)

Install Tensorflow GPU

  • Select newly created Environment (neural_tf)
  • Search for tensorflow-gpu
  • Select listed packages
  • Click on Apply
  • Install packages by clicking Apply again
  • Install Tensorflow (Source: iNNovationMerge)
  • Install Tensorflow (Source: iNNovationMerge)

Install Keras

  • Select newly created Environment (neural_tf)
  • Search for keras
  • Select listed packages
  • Click on Apply
  • Install packages by clicking Apply again
  • Install Keras (Source: iNNovationMerge)

Install CUDA Tookit 10.0

  • Open link CUDA Toolkit Archive

  • Select CUDA Toolkit 10.1

  • Select

    • Operating System -> Windows
    • Architecture -> x86_64
    • Version -> 10
    • Installer Type -> exe
    • Download the exe
    • Run and Install
  • Install Cuda Toolkit (Source: iNNovationMerge)

  • Install Cuda Toolkit (Source: iNNovationMerge)

Download cuDNN 10.1

Set Environmental Variables

  • Unzip downloaded zip file to any folder(C:\cudnn-10.1-windows10-x64-v8.0.5.39)
  • Add its bin path to the Environmental Variables
    • C:\cudnn-10.1-windows10-x64-v8.0.5.39\cuda\bin
  • Add Nvidia Smi folder path to the Environmental Variables
    • C:\Program Files\NVIDIA Corporation\NVSMI
  • Set Environment Variable (Source: iNNovationMerge)

Check Nvidia Driver installation

  • Open command prompt

  • Run command : nvidia-smi

  • You should be able to see the GPU information as below

  • nvidia-smi (Source: iNNovationMerge)

Testing by invoking GPU from Tensorflow

  • Open command prompt

  • Activate environment by running below command

    • conda activate neural_tf
  • Run below code

    import os
    os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
    import tensorflow as tf
    gpus = tf.config.experimental.list_physical_devices('GPU')
    print(gpus)
    
    # Output:
    # [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
  • Testing installation (Source: iNNovationMerge)

Great, iNNovationMerge hope that you have understood how to install and Run tensorflow on GPU


  TOC