0

code:

from theano import function, config, shared, tensor
import numpy
import time
#import lasagne

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([], tensor.exp(x))
print(f.maker.fgraph.toposort())
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, tensor.Elemwise) and
              ('Gpu' not in type(x.op).__name__)
              for x in f.maker.fgraph.toposort()]):
    print('Used the cpu')
else:
    print('Used the gpu')

Results:

C:\Users\spk7522\AppData\Local\Continuum\Anaconda3\python.exe C:/Users/spk7522/Desktop/python/test.py WARNING (theano.sandbox.cuda): The cuda backend is deprecated and will be removed in the next release (v0.10). Please switch to the gpuarray backend. You can get more information about how to switch at this URL: https://github.com/Theano/Theano/wiki/Converting-to-the-new-gpu-back-end%28gpuarray%29

Using gpu device 0: Quadro K4000 (CNMeM is enabled with initial size: 95.0% of memory, cuDNN 5110) [GpuElemwise{exp,no_inplace}(), HostFromGpu(GpuElemwise{exp,no_inplace}.0)] Looping 1000 times took 0.471953 seconds Result is [ 1.23178029 1.61879349 1.52278066 ..., 2.20771813 2.29967761 1.62323296] Used the gpu

Process finished with exit code 0

QRS: 1) Is my theano test program working fine with GPU 2) How to remove WARNING (theano.sandbox.cuda): message on window cmd

shiva
  • 29
  • 1
  • 3
  • Click the link to fix the warning – OneCricketeer Apr 01 '17 at 22:00
  • The answer to 1) looks like yes, assuming those numbers are right. The answer to 2) appears to be in the warning message - it's got a URL there you can look at. It looks like your Results section answers both your questions, which is neat. :) – bouteillebleu Apr 01 '17 at 22:01
  • I am not getting clear steps from the above link above and using vc++ 2013. I doing it on windows env only. Would you please give some other link where i can easily figure out things – shiva Apr 03 '17 at 05:34

0 Answers0