Configure Theano GPU Support

If you followed the steps on how to install theano on windows in my previous blogpost, you are ready to configure GPU Acceleration. Telling theano to use the GPU on a windows machine is quite simple:

1) Intall Visual Studio 2013 Enterprise Edition. (not express as it does not install some x64.bat files) and also not Visual Studio 2015 as it is still not supported! )
2) Install Cuda 7.5 Toolkit (you have to get registered in the Nvidia community to get the download)
3) Create a File in your User Home directory(For me this is C:\Users\Lukas) named .theanorc.txt with the following text:



device = gpu

floatX = float32


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


4) Test your configuration using the following python script: (you can save it to a file e.g and run it by open a commandshell in elevated mode and run python (Script taken from

##see if gpu is used

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‘)

Titel Picture from Larry Browns Blogpost on “How to accelerate Machine Learning with GPUs”


2 Gedanken zu “Configure Theano GPU Support

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

Du kommentierst mit Deinem Abmelden / Ändern )


Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )


Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s