While “The Chaos Rift” isn’t well known for being techy, this is my true profession. Professionally speaking, I’m in the Data Sciences field and have been mucking around with AI for years. My forrays into AI have mostly been for hobbyist Game development. Lately I’ve expanded the hobby to real world applications. With the release of Tensorflow in 2015, that was the major push. I dropped PERL scripting and learned Python development.
But there are pitfalls to running a Windows OS. A lot of the Deep learning libraries do not like to run on it. Torch* (see bottom) for instance require some special nudges and undocumented commands to get working. Originally Tensorflow was not on PC, though times have changed. Now installing Tensorflow with CPU acceleration is a no brain “pip install tensorflow” and useful for most people starting out. However for serious computing, GPU acceleration is highly recommended. A small dataset of 10,000 images (yeah that’s small) took 3 hours to complete a single epoch. With GPU each epoch (total 25) took 20 minutes. Needless to say the benefits outweigh the setup cost.
But there were pitfalls to the setup, and documentation is a bit sparse. So here it is:
Requirements
- Anaconda Python While not “technically” required, Anaconda is the defacto standard for Data Science installations of Python. It’s one I use exclusively at work, despite it not being “standard” software.
- Nvidia CUDA GPU. You can check here if your GPU is CUDA compatible. I know finally a non game use for an Nvidia card since ATI has nailed the Crypto Currency market.
- CUDA® Toolkit 8.0 This is the core API and needed.
- cuDNN v5.1 for CUDA toolkit 8.0. Note: DO NOT Install 6.0 or any “newer” versions. It will not work.
Setting up your Nvidia GPU
You need to install Cuda Toolkit 8.0 and cuDNN v5.1 as the GPU version works best with these.
Download and install CUDA Toolkit
Toolkit version 8.0 or above: https://developer.nvidia.com/cuda-downloads
Example installation directory: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0
Download and install cuDNN
cuDNN version 5.1 library for Windows 10: https://developer.nvidia.com/cudnn
You need to signup at Nvidia in order to download these files. Now open “cudnn-8.0-windows10-x64-v5.1.zip” and extract the files into your Toolkit directory. Make sure you open cuda directory first then extract the lib, include, bin directories.
Environmental variables
The Toolkit install sets most of them up. But you’ll need to add “CUDA_HOME“. This is found by typing “View Advanced System Settings” in the Cortana bar. Then click “Environment Variables” button on the bottom.
You’ll have to add these two lines to the user PATH.
Install Anaconda
This is the Easy part. Install Anaconda as it helps us to easily manage separate environments for specific distributions of Python, without disturbing the version of python installed on your system.
Download and install
Anaconda
Create conda environment
This is really optional. I find managing environments on my PC a nightmare. Granted if I’m doing web development with Django, or you want to freeze a package with Pyinstaller, then yeah, environments are important. Create new environment, with the name tensorflow-gpu.
conda create -n tensorflow-gpu
Activate environment we created
activate tensorflow-gpu
Install tensorFlow
There’s a lot to install. As you can see, I’ve already got the packages installed.
Done. You have successfully installed TensorFlow with GPU on your Windows machine.
Now lets test if it is using GPU…
Test GPU
Enter into python shell
python
import tensorflow as tf
Now run this command and check if it identifies your GPU.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
The Beauty of GPU Accelerated AI
We’re done! You now have Tensorflow installed on your evil Windows PC and area ready to create self aware algorithms. Here’s an image of it working in the Spyder IDE processing through 8000 pictures of dogs and cats.
Bonus Material
Installing pyTorch on Windows 10 with GPU support is really easy thanks to Github’s peterjc123.
conda install -c anaconda python=3.6.1 conda install -c peterjc123 pytorch=0.1.12
Keras
Keras is a great package for deep learning with Python. It’s essentially a “simplified” front end for Tensorflow or Theano. Simply “pip install keras”
That’s it. I’ll be writing more AI articles as I personally progress through my machine learning adventures.
Tell us how you really feel!