![](/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.