我尝试运行GPU使用的测试程序:
from theano import function, config, shared, tensor, sandbox
import numpy
import time
vlen=10*30*768 #10x #coresx #threadspercore
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 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, 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 gnu')
它只显示此内容(即使在安装libgpuarray
后):
[Elemwise{exp,no_inplace}(<TensorType(float64, vector)>)]
Looping 1000 times took 2.723539 seconds
Result is [ 1.23178032 1.61879341 1.52278065 ..., 2.20771815 2.29967753
1.62323285]
Used the cpu
我想知道如何利用MacBook Air的集成GPU(2014年初)。
我的处理器有Intel HD Graphics 5000 - 不是NVIDIA,因此不兼容CUDA很多links建议使用OpenCL。这也应该预先安装OS-X。但是,我不能在网络链接中做出头或尾。
我无法在docs中找到如何设置Theano的帮助。
我只需要让Theano使用我的Mac的集成GPU。这可能吗?如果是这样,怎么样?它的先决条件是什么?
答案 0 :(得分:0)
THEANO_FLAGS=device=opencl0:1 python ~/check_GPU.py