【发布时间】:2016-07-28 20:05:52
【问题描述】:
我尝试运行 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(2014 年初)的集成 GPU。
我的处理器有 Intel HD Graphics 5000 -- 不是 NVIDIA,因此不兼容 CUDA 许多links 建议使用 OpenCL。这也应该预装在 OS-X 中。但我无法从网络中的链接中脱颖而出。
我也找不到太多关于如何在docs 中设置 Theano 的帮助。
我只需要让 Theano 使用我的 Mac 的集成 GPU。这可能吗?如果是这样,怎么做?它的先决条件是什么?
【问题讨论】:
-
你是如何运行代码的?您是否包括了 THEANO_FLAGS=device=gpu?无论如何,在我看来,使用内置 GPU 卡不会获得合理的加速。
-
如何指定这些标签,@sygi?我应该在命令行中执行此操作吗?我正在为此使用 Ipython 笔记本。您能否为此提供具体说明?
标签: macos installation theano gpu