![](/img/trans.png)
[英]After Training Model with Keras GPU memory is full and cannot be cleared
[英]Jupyter Notebook GPU memory release after training model
在使用 Jupyter notebook 完成深度学习 model 训练后,我们如何清理 GPU memory。 问题是,无论我坚持使用什么框架(tensorflow,pytorch),存储在 GPU 中的 memory 都不会被释放,除非我手动终止进程或终止 Z50484C19F1AFDAF3841A0D821ED3 并重新启动。 您知道我们如何通过自动化步骤来解决这个问题吗?
我发现的唯一解决方法是使用线程。 使用子流程执行培训。
一个例子:
def Training(arguments):
....
....
return model
if __name__=='__main__':
Subprocess = Process(# The complete function defined above
target = Training,
# Pass the arguments defined in the complete function
# above.
# Note - The comma after the arguments : In order for
# Python
# to understand this is a tuple
args = (arguments, ))
# Starting the defined subprocess
Subprocess.start()
# Wait for the subprocess to get completed
Subprocess.join()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.