My code is from an older version of your code, so I mistakenly deleted the part of choosing a gpu.
I also changed the model to work in python 3.5 and tensorflow 0.12, which accounts for some changes like pickle becoming cPickle and adding explicit conversions to int.
Notice: