CUDA out of memory in pytorch

with torch.no_grad():

CUDA out of memory in pytorch

今天尝试了一下Transformer,一直遇到当validate若干次之后爆显存,一开始以为参数过多,batch size过大,但是无济于事。谷歌了相关内容,发现原来是需要加

with torch.no_grad():

torch.cuda.empty_cache()  

这些效果都不明显

发布了2857 篇原创文章 · 获赞 1113 · 访问量 584万+

猜你喜欢

转载自blog.csdn.net/jacke121/article/details/105679599