gpt4 book ai didi

python-2.7 - 你如何释放gpu内存?

转载 作者:行者123 更新时间:2023-12-03 16:50:29 36 4
gpt4 key购买 nike

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

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)'")

最佳答案

如果 borrow 设置为 true 垃圾回收开启(默认 true:config.allow_gc=True)并且视频卡当前未被用作显示设备(值得怀疑,因为您使用移动 gpu),唯一的其他选择是减少网络参数或可能减少模型的批量大小。如果模型使用 dropout 或基于噪声的掩码(这些将等于批处理中的示例数量 x 被丢弃或噪声的参数数量),后者将特别有效。

否则也许您可以启动到命令提示符以节省几 mb?:/

关于python-2.7 - 你如何释放gpu内存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32936166/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com