如何释放gpu内存? [英] How do you free up gpu memory?

查看:1328
本文介绍了如何释放gpu内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

When running theano, I get an error: not enough memory. See below. What are some possible actions that can be taken to free up memory? I know I can close applications etc, but I just want see if anyone has other ideas. For example, is it possible to reserve memory?

THEANO_FLAGS = mode = FAST_RUN,device = gpu,floatX = float32 python conv_exp.py使用gpu设备0:GeForce GT 650M尝试在以下环境下运行 GPU.如果不需要,请修改network3.py来设置GPU 标记为False. 分配156800000字节的设备内存时出错(输出 的内存).驱动程序报告64192512字节空闲和1073414144字节 总计回溯(最近一次通话最近):文件"conv_exp.py",行 25英寸 training_data,validation_data,test_data = network3.load_data_shared()文件 "/用户/xr/课程/deep_learning/con_nn/neural-networks-and-deep-learning/src/network3.py", 第78行,在load_data_shared中 返回[shared(training_data),shared(validation_data),shared(test_data)]文件 "/用户/xr/课程/deep_learning/con_nn/neural-networks-and-deep-learning/src/network3.py", 共享的第74行 np.asarray(数据[0],dtype = theano.config.floatX),借位= True)文件 "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/theano/compile/sharedvalue.py", 共享的208行 allow_downcast = allow_downcast,** kwargs)文件"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/theano/sandbox/cuda/var.py", 第203行,在float32_shared_constructor中 deviceval = type_support_filter(value,type.broadcastable,False,None)MemoryError :(分配设备内存的156800000字节错误 (内存不足).",您可以考虑使用'theano.shared(..., 借用= True)')

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

推荐答案

如果将rows设置为true,则将启用垃圾收集(默认为true:config.allow_gc=True),并且当前未将视频卡用作显示设备(可疑) ,因为您使用的是移动GPU),唯一的其他选择是减少网络参数或减少模型的批量大小.如果模型使用丢包或基于噪声的蒙版(后者等于批中示例的数量x丢包或受噪的参数的数量),则后者将特别有效.

If borrow is set to true garbage collection is on (default true: config.allow_gc=True) and the video card is not currently being used as a display device (doubtful, since you're using a mobile gpu), the only other options are to reduce the parameters of the network or possibly the batch size of the model. The latter will be especially effective if the model uses dropout or noise-based masks (these will be equal to the number of examples in the batch x the number of parameters dropped out or noised).

否则,您可以引导至命令提示符以节省几mbs? :/

Otherwise maybe you could boot to the command prompt to save a few mbs? :/

这篇关于如何释放gpu内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆