Visual Studio 15, Anaconda 64, Theano, Keras, TensorFlow, CUDA, CuDNN on Windows 10 64-bit with GPU.

This worked for me:

  1. Install Visual Studio 15 Community Edition.  If you can enable Python during installation, do so.  Otherwise fire it up post install, and use NuGet to install Python Tools for Visual Studio.
  2. Install CUDA 8.0 or higher (follow all defaults)
  3. Install CuDNN… by this, I mean download it… it’s just a zip with bin, lib, and include directories.  Extract the contents of each of these to the corresponding bin, lib, and include folders under your CUDA’s install folder. (CUDA’s “official” install will have added these to various paths; placing the CuDNN stuff in these locations ensures they will be found by whatever CUDA-enabled process may be looking for them later on).
  4. Install Anaconda 64 bit 3.5 version… (that’s right… not 2.7… reason: TensorFlow requries 3.5… all other dependencies are OK on 2.7; if TensorFlow ever comes along on 2.7, then we’ll be OK there.)
  5. Fire up Visual Studio… create a Python project… it should find Anaconda and display it under your Solution Explorer…
  6. In Visual Studio, right-click on the “Python 64-bit 3.5” python environment, and select “Open Command Prompt Here…” (this basically gives you the Anaconda command prompt).
  7. On the command prompt:
    1. run conda update conda
    2. run conda update –all
    3. run conda install mingw libpython
    4. run pip install git+git://
    5. run pip install git+git://
    6. run pip install tensorflow (optional)
  8. Exit the command prompt.
  9. In the Anaconda3 root directory, create a .theanorc.txt file, containing:

device = gpu
floatX = float32


compiler_bindir=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin

10. In your Visual Studio project, create a simple “” file, containing (see also: this tutorial):

from theano import function, config, shared, sandbox
import theano.tensor as T
import numpy
import time

vlen = 10 * 30 * 768 # 10 x #cores x # threads per core
iters = 1000

rng = numpy.random.RandomState(22)
x = shared(numpy.asarray(rng.rand(vlen), config.floatX))
f = function([], T.exp(x))
t0 = time.time()
for i in range(iters):
    r = f()
t1 = time.time()
print("Looping %d times took %f seconds" % (iters, t1 - t0))
print("Result is %s" % (r,))
if numpy.any([isinstance(x.op, T.Elemwise) for x in f.maker.fgraph.toposort()]):
    print('Used the cpu')
    print('Used the gpu')

11. Theano might be defaulted to use tensorflow, which can generate some inexplicable errors. To disable this, edit your keras.json file to change the “backend” to “theano”.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s