您的位置:首页 > 其它

Theano和Tensorflow多GPU使用问题

2017-09-25 17:46 519 查看
我使用的是tensorflow-gpu (1.2.1)和Theano (0.9.0),2个4G显存Nvidia Quadro M2000 GPU。

1. theano: ValueError: Could not infer context from inputs 

THEANO_FLAGS="contexts=dev0->cuda0;dev1->cuda1,gpuarray.preallocate=0.95,mode=FAST_RUN,floatX=float32,on_unused_input=warn"  python config.py

ERROR (theano.gof.opt): SeqOptimizer apply <theano.gpuarray.opt.GraphToGPU object at 0xdfe69210>

ERROR: SeqOptimizer apply <theano.gpuarray.opt.GraphToGPU object at 0xdfe69210>

ERROR (theano.gof.opt): Traceback:

ERROR: Traceback:

ERROR (theano.gof.opt): Traceback (most recent call last):

  File "/usr/lib/python2.7/site-packages/theano/gof/opt.py", line 235, in apply

    sub_prof = optimizer.optimize(fgraph)

  File "/usr/lib/python2.7/site-packages/theano/gof/opt.py", line 87, in optimize

    ret = self.apply(fgraph, *args, **kwargs)

  File "/usr/lib/python2.7/site-packages/theano/gpuarray/opt.py", line 322, in apply

    target = infer_context_name(*fgraph.inputs)

  File "/usr/lib/python2.7/site-packages/theano/gpuarray/basic_ops.py", line 122, in infer_context_name

    raise ValueError("Could not infer context from inputs")

ValueError: Could not infer context from inputs 

theano不能自动支持多GPU,需要自己指定一个,只能在一个上面跑, 需要指定一个设备device=cuda0。
支持多GPU, 需要自己编程,参考http://deeplearning.net/software/theano/tutorial/using_multi_gpu.html#

2. tensorflow: ResourceExhaustedError: OOM when allocating tensor with 

    theano: MemoryError: Error allocating 1440000000 bytes of device memory (out of memory).

说明GPU内存不够,要调小输入或网络单元。

3. theano切换成新的GPU backend

WARNING (theano.sandbox.cuda): The cuda backend is deprecated and will be removed in the next release (v0.10)

theano 0.9.0从cuda backend切换gpuarray backend,需要安装python2-Cython-0.25+和libgpuarray-0.6.3+, 然后通过gpuarray.preallocate来指定。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息