【问题标题】:How to make Theano use the integrated GPU in MacBook Air?如何让 Theano 使用 MacBook Air 中的集成 GPU?
【发布时间】: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


【解决方案1】:
THEANO_FLAGS=device=opencl0:1 python ~/check_GPU.py

【讨论】:

  • 欢迎来到 Stack Overflow!虽然这段代码 sn-p 可以解决问题,但including an explanation 确实有助于提高帖子的质量。请记住,您正在为将来的读者回答问题,而这些人可能不知道您的代码建议的原因。也请尽量不要用解释性的 cmets 挤满你的代码,这会降低代码和解释的可读性!
猜你喜欢
  • 2013-08-12
  • 2015-11-09
  • 2013-07-15
  • 2015-09-12
  • 2017-04-04
  • 2017-05-13
  • 2018-11-11
  • 2016-06-23
  • 1970-01-01
相关资源
最近更新 更多