2015-10-04 201 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? 「 :/