INSTALLATION GUIDE : TENSORFLOW

Introduction to Tensorflow

TensorFlow is an end-to-end open source platform for machine learning. It has a comprehensive, flexible ecosystem of tools, libraries and community resources that lets researchers push the state-of-the-art in AI/ML. Developers get a wide source to build and deploy versatile ML powered applications using tensorflow and keras.

Types of Tensorflow Installation

When you Install tensorflow, you can choose two versions either CPU or GPU. If you are a beginner and trying to process the small or medium size data, then you should choose the CPU version. If you have a huge amount of data especially Images, then you should install the GPU version. GPU version is faster than a CPU version and it supports NVIDIA GPU, with support for CUDA Compute 3.5 or higher.You must install the following soft wares in order to run the Tensorflow GPU version:

  1. NVIDIA GPU drivers
  2. CUDA Toolkit: CUDA 9.0
  3. NCCL 2.2 (optional)
  4. cuDNN SDK (7.2 or higher)
  5. TensorRT for improved latency and throughput.
  • Tensorflow Installation with Anaconda

In windows Operating system, there are two methods used to install the tensorflow, i.e. via “Pip” or “Anaconda”. Pip stands for “Pip installs Packages” that is used for installing the python packages. And it comes with the python manager.

On the other hand, Anaconda is a great choice for Data science. Anaconda is a free and open-source distribution of python for scientific computing. Anaconda is popular because it brings many of the tools used in data science and machine learning with just one installation. Therefore, it is a good choice to have a crisp and simple setup.

Like virtual environments (virtualenv), Anaconda also uses the concept of creating environment so as to isolate different libraries and versions.

Steps of Installation are as follows:

Step1. Download the anaconda distribution from the given link https://www.anaconda.com/ .

Step2. Once the package is downloaded, double-click it to start the installation. The installer will be verified and a welcome window will pop up.

Click “Next”. In the next window, you will be required to accept the terms of the Anaconda agreement.

Step 3.

Click “I Agree”. You will be prompted to choose the installation type, whether just for you or for all users. Choose the option you need and click “Next”.

You can install Anaconda in the default directory or browse to another directory. I’ve recommended you to choose a different directory other than C Drive. Click “Next”.

Step 4. You will see the window for “Advanced installation Options”. Check the second checkbox, that is, “Register Anaconda as my default Python 3.6, and then click on the “Install” button.

Step 5. Once the installation is complete, you will get the following screen. Then click on “Next”.

Now on the last screen you have to click on the “Finish” button. Your installation is complete.

Step 6. Once anaconda is installed then go to the search bar near start menu and type here “Anaconda prompt”, and open it.

Step 7. Once the prompt is open execute the following command $ conda info, to see the information of python packages.

[ Note:This step is optional ]

Step 8. We will now create a Python virtual environment with conda. A virtual environment is a named isolated working copy of Python that maintains its own files, directories, and paths so that you can work with specific versions of libraries or Python itself without affecting other Python projects.

To create a virtual environment, execute the following command

$ conda create -n [environment-name]

Let us name the virtual environment as “tensorenv” and execute the following command

$ conda create -n tensorenv

Step 9. You will be prompted to allow the process to proceed. Just type “y” for “yes” and press the enter key on your keyboard. The environment will be created successfully.

Step 10. We can then activate the environment we have just created:

To activate this environment, run the following command $ conda activate tensorenv

Step 11. Now virtual environment is ready, run the following command to install TensorFlow in your virtual environment:

For CPU version: $ conda install tensorflow

Note [if you want to download the specific version of tensorflow then run the following command. Here we are installing tensorflow version 2.0]

$ conda install tensorflow==2.0

A list of packages to be installed alongside TensorFlow will be shown. The command will prompt you to confirm the installation of these packages. Type “y” and then press the enter key. The progress of the installation process will be shown on the command prompt. The cursor will start blinking again once the installation is complete.

Now let’s check whether our installation is working or not.

Launch a Jupyter Notebook

The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text. In order to open a jupyter notebook,

Step 1. Search anaconda navigator in start menu search bar and open it.

Step 2. Once anaconda navigator is open, click “Launch” on jupyter notebook.

Step 3. Once it is launched, click “New” → “Python 3” to create a blank notebook.

Step 4. Start to write a code

Verifying the installation

Now that TensorFlow has been installed, we can verify whether the installation was successful or not. To do so, we can run Python’s import statement and see if we can successfully import the TensorFlow library.

import tensorflow as tf

  • Tensorflow Installation with pip

pip is the standard package manager for Python. It allows you to install and manage additional packages that are not part of the Python standard library.

Step 1. To get the pip package manager, you first need to install Python. Download the latest version of Python from the official Python website and install it.

Step 2. Once the installation completes, check for the version of pip running on your system. To do so, run the command prompt and type:

$ pip — version

Since you have installed the latest version of Python, that is, Python 3.x, you have pip3, and not pip. The latter was used with Python 2.7.

Step 3. To install tensorflow. Run the windows command prompt as an administrator. To do so, go to the start menu on your Windows machine, search for “cmd”, right click it and choose “Run as administrator”.

Step 4. After that, you only have to run one simple command to install tensorflow.

$ pip3 install — upgrade tensorflow

The command will take some time to execute, so remain patient. With pip, you can install tensorflow with GPU support as follows:

$ pip3 install tensorflow-gpu

!! Congratulations. Tensorflow is installed in your system!!