使用sudo运行时,Keras会抛出错误

时间:2017-07-20 09:34:55

标签: python keras

当我使用sudo sudo KERAS_BACKEND=theano python train.py运行我的Keras训练脚本时,我在一段时间后收到错误:

Traceback (most recent call last):
  File "train.py", line 186, in <module>
    loss=siamese_net.train_on_batch(inputs,targets)
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 1565, in train_on_batch
    outputs = self.train_function(ins)
  File "/usr/local/lib/python2.7/dist-packages/keras/backend/theano_backend.py", line 1197, in __call__
    return self.function(*inputs)
  File "/usr/local/lib/python2.7/dist-packages/theano/compile/function_module.py", line 898, in __call__
    storage_map=getattr(self.fn, 'storage_map', None))
  File "/usr/local/lib/python2.7/dist-packages/theano/gof/link.py", line 325, in raise_with_op
    reraise(exc_type, exc_value, exc_trace)
  File "/usr/local/lib/python2.7/dist-packages/theano/compile/function_module.py", line 884, in __call__
    self.fn() if output_subset is None else\
  File "/usr/local/lib/python2.7/dist-packages/theano/gof/op.py", line 872, in rval
    r = p(n, [x[0] for x in i], o)
  File "/usr/local/lib/python2.7/dist-packages/theano/tensor/blas.py", line 1544, in perform
    z[0] = numpy.asarray(numpy.dot(x, y))
MemoryError:
Apply node that caused the error: Dot22(InplaceDimShuffle{1,0}.0, Elemwise{Composite{(i0 * i1 * (i2 - i1))}}[(0, 1)].0)
Toposort index: 162
Inputs types: [TensorType(float32, matrix), TensorType(float32, matrix)]
Inputs shapes: [(112896, 32), (32, 4096)]
Inputs strides: [(4, 451584), (16384, 4)]
Inputs values: ['not shown', 'not shown']
Outputs clients: [[Gemm{inplace}(Dot22.0, TensorConstant{1.0}, InplaceDimShuffle{1,0}.0, Elemwise{Composite{(i0 * i1 * i2 * (i3 - i2))}}[(0, 1)].0, TensorConstant{1.0})]]

HINT: Re-running with most Theano optimization disabled could give you a back-trace of when this node was created. This can be done with by setting the Theano flag 'optimizer=fast_compile'. If that does not work, Theano optimizations can be disabled with 'optimizer=None'.
HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.

然而,当我只执行没有sudo KERAS_BACKEND=theano python train.py的python脚本时,它开始按预期运行,至少就我所见。这怎么可能?

0 个答案:

没有答案