Python Jupyter笔记本电脑GPU内存释放训练后模型

Python Jupyter笔记本电脑GPU内存释放训练后模型,python,memory-management,deep-learning,jupyter-notebook,gpu,Python,Memory Management,Deep Learning,Jupyter Notebook,Gpu,在使用Jupyter笔记本完成深度学习模型训练后,我们如何清除GPU内存。问题是,无论我坚持使用什么框架(tensorflow,pytorch),存储在GPU中的内存都不会被释放,除非我手动终止进程或终止内核并重新启动Jupyter。你知道如何通过自动化这些步骤来解决这个问题吗?我发现唯一的解决方法就是使用线程。使用子流程执行培训 例如: def Training(arguments): .... .... return model if __name__=='_

在使用Jupyter笔记本完成深度学习模型训练后,我们如何清除GPU内存。问题是,无论我坚持使用什么框架(tensorflow,pytorch),存储在GPU中的内存都不会被释放,除非我手动终止进程或终止内核并重新启动Jupyter。你知道如何通过自动化这些步骤来解决这个问题吗?

我发现唯一的解决方法就是使用线程。使用子流程执行培训

例如:

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()