Building algorithmic agents with neural networks is the go-to business strategy in the current technology environment. Now, Google’s Tensorflow library helps developers build these agents with pre-defined functions for easy implementations of various tasks. In this article, we shall be going through the steps to setup an environment for development of these models with Tensorflow library. Setting up an environment for these tasks is mandatory because each model you build is unique to one another and have different dependencies.
As part of the first step, one should download Python. Tensorflow is available on both Python 2 and Python 3. You can download it from here. Once you have downloaded the desired version, you have to set up the environment variables.
You can access the environment variables by either typing it Start menu (Win 8 and Win 10). Or you can go here:
My Computer > Properties > Advanced System Settings > Environment Variables>
You have to add the
path of your python. If it is a default Windows installation, the default path will be C:/Python36 for Python 3. If everything has been setup correctly, you can test it by typing
python in the command prompt. The output should be as follows:
Setup Virtual Environment
PIP is a installer package for Python which stands for Python Installer Package. If one faces problems with Pip, it is accessible here.
Download get-pip.py, be careful to save it as a
.py file rather than
.txt. One you are in the directory where the file is downloaded, on command prompt run,
Once pip is set, we shall setup the virtual environment with virenv available for Python.
pip install virtualenv
You have to navigate to the Scripts folder and run the activate command to activate the environment. Here’s how it is done:
Install Tensorflow (CPU/GPU)
Once you have setup all these, you can now install the Tensorflow library. It is as simple as installing the virtualenv. Depending on which version you desire, Tensorflow has a GPU extension which can be accessed by having CUDA and cuDNN installed.
Once you have the environment set for the installation of Tensorflow, you can run the following command to install the CPU version of Tensorflow. If everything is setup right, the packager will download and install all the dependencies required for Tensorflow and eventually the CPU version.
If you need the GPU extension of Tensorflow for better computational speed and performance of your system, then you need to install the CUDA and cuDNN from the Nvidia.
Note: Tensorflow currently supports Nvidia GPU cards only.
CUDA toolkit can be downloaded here, and it is similar to setting up the path in the environment during the Python installation, one has to follow the same steps to setup the CUDA toolkit.
Also, cuDNN has to be setup and can be downloaded from here.
Based on our experience, we had to downgrade the CUDA installation to 9.0 version and cuDNN to version 7.0 since there were a few problems with the newer versions of CUDA and cuDNN. Hope this has been resolved and updated. Once everything has been setup, the following code will run smoothly.
Once we have reached this stage, it is time to test if Tensorflow is working or not. We can start by importing it on Python.
It works like a charm and finally we have setup the environment and you can start playing around with neural nets now. Also, you can install Jupyter Notebook inside the environment if you are a notebook person. This will open in a new browser window and its easy to install with the following code
pip install jupyter
With these steps one can easily setup the environment required Tensorflow computations. Also, with the GPU extension, the models run exceptionally faster compared to running them on CPUs.
Try deep learning using MATLAB