In [9]:
#from theano import function, config, shared, sandbox, 
import theano
theano.config.device = 'gpu'
theano.config.floatX = 'float32'

import theano.tensor as T
import numpy
import time


---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-9-0c5939595d75> in <module>()
      1 #from theano import function, config, shared, sandbox,
      2 import theano
----> 3 theano.config.device = 'gpu'
      4 theano.config.floatX = 'float32'
      5 

/home/hpc_dmytro/python/lib/python2.7/site-packages/theano/configparser.pyc in __set__(self, cls, val)
    325         if not self.allow_override and hasattr(self, 'val'):
    326             raise Exception(
--> 327                 "Can't change the value of this config parameter "
    328                 "after initialization!")
    329         # print "SETTING PARAM", self.fullname,(cls), val

Exception: Can't change the value of this config parameter after initialization!

In [8]:
#config.device = 'gpu'
#config.floatX = 'float32'

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

rng = numpy.random.RandomState(22)
x = theano.shared(numpy.asarray(rng.rand(vlen), config.floatX))
f = function([], T.exp(x))
print(f.maker.fgraph.toposort())
t0 = time.time()
for i in xrange(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')
else:
    print('Used the gpu')


---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-8-97a4d54a85e6> in <module>()
----> 1 config.device = 'gpu'
      2 #config.floatX = 'float32'
      3 
      4 vlen = 10 * 30 * 768  # 10 x #cores x # threads per core
      5 iters = 1000

/home/hpc_dmytro/python/lib/python2.7/site-packages/theano/configparser.pyc in __set__(self, cls, val)
    325         if not self.allow_override and hasattr(self, 'val'):
    326             raise Exception(
--> 327                 "Can't change the value of this config parameter "
    328                 "after initialization!")
    329         # print "SETTING PARAM", self.fullname,(cls), val

Exception: Can't change the value of this config parameter after initialization!

In [ ]: