When it comes to deep learning; the first thing comes to your mind is the “Computation Power”. The thousands of matrix operations that you going to perform when training the deep neural networks would take ages if you going to use only the CPU to do it.
The solution is the Graphical Processing Units (GPUs).
There are few ways that you can get the power of high computation power for deep learning.
- Build a system powered with a GPU. (Would cost a bit 😉)
- Provision a virtual machine powered with a GPU (AWS, Azure both provide GPU powered VMs)
- Using a cloud computation tool as Azure Batch AI (Currently in preview) (https://azure.microsoft.com/en-us/services/batch-ai/)
No offence, in my experience Linux operating system (What I’m using is the Ubuntu flavor) comes handy with performing deep learning operations in python because the terminal, bash commands, open source editing tools, GPU hackability is bit easy for me in Linux.
But the recent windows and Visual Studio updates too make it possible to do deep learning on your Windows rig.
Here are the steps I’ve followed to configure my laptop to perform some DL based computations with Tensorflow and Keras.
The laptop I’m using is an Asus UX310UA with Core i7 7th Gen processor, 16GB RAM and Nvidia Geforce 940MX 2 GB GPU.
I’m running Windows 10 Enterprise 1703 build on my laptop.
Please note that the following steps may change according to some conditions.
- Check the GPU processing capability of your GPU
If you wish to use your GPU for do parallel processing, first check the CUDA supportability of your GPU device. More the CUDA cores you have, more the computation you get. As an example, Nvidia Tesla K80 is having 4992 CUDA cores while Geforce 940MX equipped with 384 CUDA cores. The GPU compute capability should be 3.0 or higher.
Check whether your GPU is listed in the list.
- Install CUDA Toolkit
Installing CUDA on Windows has a dependency for a C++ compiler. The CUDA version I’ve installed in my laptop is CUDA 8.0. Along with that I’ve installed Visual C++ 15.0 compiler. Refer the following guide to install CUDA Toolkit for your computer.
- Install CuDNN Tools
For faster computations, you need to install CUDA Deep Neural Network toolkit. Depends on the CUDA version that you’ve installed you should select the appropriate CuDNN version. In my case with CUDA 8.0 Both CuDNN 7.0 & CuDNN 6.0 works. When it comes to package installations, CuDNN 7.0 throwed me some errors. So, I went with CuDNN 6.0 and it’s working fine on my machine 😊
Note that you need to do some manual file copy pastings in this step.
For safe side, restart the machine now! It’ll then pop up any additional dependencies that the GPU ask you to install.
- Install Anaconda
Now it’s time for the Big Snake! Anaconda is the leading Python data science platform. This framework comes with many pre-installed essential libraries and configurations that you may need regularly. Go with Python3 since it is the latest.
- Create a python environment for your experiments
Python comes with hell a lot of libraries that you may need to compile your program. So best thing is to create a separate environment for deep learning and use it. It’ll secure you from tangling the dependencies among libraries.
Go for Anaconda prompt (Find it on start menu – Advised to open the conda prompt as administrator) and push the command. We are using python 3.5 at the moment. ‘tensorflow-gpu’ is the environment name.
Activate the environment
- Install Theano
Theano is a Python library that allows you to define, optimize, and evaluate mathematical expressions involving multi-dimensional arrays efficiently. We need it! Make sure you are installing all of these inside your environment.
- Install mingw python
Even though python is an interpreted language, you may ned to install Windows C++ compilers in some cases. For python 3.5/3.6 you can use Visual C++ 14.0 compiler.
- Install tensorflow
Tensorflow is an open source library for numerical computation. You can install the cpu version if you don’t have a GPU in your machine just by installing the CPU version.
- Install keras
Keras is a high-level neural network API. It can sun on top of TensorFlow, CNTK or Theano. For coding easiness will install Keras too.
- Update all the packages
All set! 😊 now you are ready to start coding. Start with your favorite IDE. For me, I prefer Spyder and sometimes Visual Studio. You can directly go for spyder from your Anaconda prompt or Anaconda navigator.
Will discuss on dealing with python on Visual Studio in the next article.