Theano-GPU-的window7-python3.6-Anaconda3

时间:2017-04-01 21:59:05

标签: python theano theano-cuda

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

结果:

C:\ Users \ spk7522 \ AppData \ Local \ Continuum \ Anaconda3 \ python.exe C:/Users/spk7522/Desktop/python/test.py 警告(theano.sandbox.cuda):不推荐使用cuda后端,将在下一版本中删除(v0.10)。请切换到gpuarray后端。您可以获得有关如何切换此URL的更多信息:  https://github.com/Theano/Theano/wiki/Converting-to-the-new-gpu-back-end%28gpuarray%29

使用gpu device 0:Quadro K4000(CNMeM启用初始大小:95.0%的内存,cuDNN 5110) [GpuElemwise {exp,no_inplace}(),HostFromGpu(GpuElemwise {exp,no_inplace} .0)] 循环1000次,耗时0.471953秒 结果是[1.23178029 1.61879349 1.52278066 ...,2.20771813 2.29967761   1.62323296] 使用了gpu

处理完成,退出代码为0

QRS: 1)我的theano测试程序是否适用于GPU 2)如何删除警告(theano.sandbox.cuda):窗口cmd上的消息

0 个答案:

没有答案