There is a lot of hoopla surrounding Deep Learning along with the ignorance about how to actually start getting hands dirty in deep learning. This problem would be more pervasive among the beginners and developers who want to start hands-on deep learning after exploring machine learning techniques. This blog-post demonstrates easy steps to set up the environment for deep learning using Keras with Tensorflow-GPU as back end.

About Keras

Keras is a high-level neural networks API, written in Python and capable of running on top of TensorFlow. It was developed with a focus on enabling fast experimentation. Being able to go from idea to result with the least possible delay is key to doing good research.

Use Keras if you need a deep learning library that:

  • Allows for easy and fast prototyping (through user friendliness, modularity, and extensibility).
  • Supports both convolutional networks and recurrent networks, as well as combinations of the two.
  • Runs seamlessly on CPU and GPU

Coming back to setting it up, I have an Acer Aspire laptop (i5 processor with 8 GB RAM) with Nvidia-Geforce-940MX GPU card and have installed Windows on it (though I prefer linux for work). I expect a similar situation with a lot of beginners who are more comfortable with having Windows on their laptops. This guide will follow easy steps to get a working environment for deep learning, utilizing the GPU on your systems.

1. Install Anaconda (Python 3.6)

This is simple. Go to this page. Download the Anaconda 64-bit installer for Windows. A simple graphical installer will install it for you. Do not forget to add the installation path  to your PATH environment variable (though it says its not recommended but check the box so that you don’t have to do the same manually afterwards). Basically, both the boxes should be checked in the below image.


Once it is successfully installed, open the Anaconda Prompt and type the following command(s) to update conda packages.

conda update conda
conda update --all

2. Install CUDA Toolkit 8.0

Download CUDA Toolkit 8.0 from here. Being an older version, it’s there in the CUDA toolkit archive. You have to select local exe for your target platform (operating system) as shown below.

This slideshow requires JavaScript.

Download the base installer as well as the Patch 2. If the format of base exe installer is not recognized then rename it by adding ".exe" extension. You will have to install the base installer first followed by installation of patch.

3. Download and unzip CuDNN

You will have to sign up to Nvidia’s site in order to download the CuDNN library. You can download cuDNN v5.1 (Jan 20, 2017), for CUDA 8.0 from here. We only have to unzip the folder and place it in C drive as they are dll and library files.


Add CuDNN to the environment path variable. Precisely you will have to add the following two paths to environment variable “PATH”.


4. Set up Conda Environment for Tensorflow Installation

Execute the following commands to set up a conda environment and install tensorflow within the environment.

#Create a conda environment "tensorflow" with Python 3.5
conda create -n tensorflow python=3.5 numpy scipy matplotlib spyder

#Activate tensorflow environment created
activate tensorflow

#Install the tensorflow with GPU support using pip
pip install --ignore-installed --upgrade

5. Install Keras

Open a new Anaconda command prompt, activate the “tensorflow” environment and type:

>> pip install keras

6. Managing packages in Conda Environment

By now, you must have understood that all the packages are installed for the conda environment named “tensorflow” created in step 4. It means that we have confined deep learning related work to an environment. Tensorflow and Keras libraries are not known outside the environment. Also, It should be obvious that any other required library needs to be installed in the environment only. We may need machine learning library “scikit-learn” or “Python Imaging Library” installed for some task in the same environment. It can be done using following commands on anaconda prompt:

>> activate tensorflow
>> pip install Pillow
>> conda install scikit-learn

7. Test Your Code

Now, one can run his/her Keras code using tensorflow as backend with Nvidia GPU support. I ran, an object recognition task using shallow 3-layered convolution neural network on CIFAR-10 image dataset. If you followed all the steps right from beginning, open a new anaconda prompt and type:

>> activate tensorflow
>> python

One can see that accuracy of 76% has been achieved on test set as shown below:


If you are not aware about CIFAR-10 dataset and object recognition task, do not worry. I will be coming up with next blog-post explaining the task and how we can achieve state-of-the-art performance.

End Remarks

Hope the blog-post guides the readers using Windows in getting started with deep learning. Check out my other blog-posts which implement machine learning and deep learning models in various applications.

Share it so that it reaches out to beginners who can be benefited from this blog-post.

Happy deep learning 🙂