2015-10-04 203 views
3

运行theano时,出现错误:内存不足。见下文。 可以采取什么措施释放内存? 我知道我可以关闭应用程序等,但我只想看看是否有人有其他想法。例如,是否可以保留内存?如何释放gpu内存?

THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python conv_exp.py Using gpu device 0: GeForce GT 650M Trying to run under a GPU. If this is not desired, then modify network3.py to set the GPU flag to False. Error allocating 156800000 bytes of device memory (out of memory). Driver report 64192512 bytes free and 1073414144 bytes total Traceback (most recent call last): File "conv_exp.py", line 25, in training_data, validation_data, test_data = network3.load_data_shared() File "/Users/xr/courses/deep_learning/con_nn/neural-networks-and-deep-learning/src/network3.py", line 78, in load_data_shared return [shared(training_data), shared(validation_data), shared(test_data)] File "/Users/xr/courses/deep_learning/con_nn/neural-networks-and-deep-learning/src/network3.py", line 74, in shared np.asarray(data[0], dtype=theano.config.floatX), borrow=True) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/theano/compile/sharedvalue.py", line 208, in shared allow_downcast=allow_downcast, **kwargs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/theano/sandbox/cuda/var.py", line 203, in float32_shared_constructor deviceval = type_support_filter(value, type.broadcastable, False, None) MemoryError: ('Error allocating 156800000 bytes of device memory (out of memory).', "you might consider using 'theano.shared(..., borrow=True)'")

+0

”你可能会考虑使用'theano.shared(...,borrow = True)'“来提示错误信息。我会给那一枪。 – msw

+0

在Theano计算运行很长一段时间或初始化过程之后会发生这种情况吗? –

+1

@msw借用已经是真的。首先检查。 – yalis

回答

3

如果借设置为true垃圾收集是(默认为true:config.allow_gc=True)和视频卡目前没有被用作显示装置(值得怀疑,因为您使用的是移动GPU)时,只有其他选项可以减少网络的参数或模型的批量大小。如果模型使用丢失或基于噪声的掩模(这些将等于批量中的示例数量x参数丢失或噪声的数量),后者将特别有效。

否则,也许你可以启动到命令提示符保存几mbs? “ :/