当前位置:主页 > 软件编程 > Python代码 >

pytorch程序异常后删除占用的显存操作

时间:2021-03-08 11:41:03 | 栏目:Python代码 | 点击:

1-删除模型变量

del model_define

2-清空CUDA cache

torch.cuda.empty_cache()

3-步骤2(异步)需要一定时间,设置时延

time.sleep(5)

完整代码如下:

del styler 
torch.cuda.empty_cache() 
time.sleep(5)

您可能感兴趣的文章:

相关文章