DEBUG:pytorch训练时候没有问题,预测时候内存迅速增长,爆掉,out of memory的解决办法
·
在使用pytorch训练模型的时候,训练时候,内存十分平稳,预测的时候迅速增长,报内存不足的错误
原始是忘记加no_grad
解决方法:在预测的时候,加with torch.no_grad()
with torch.no_grad():
for i,batch in enumerate(test_loader):
pass
更多推荐
在使用pytorch训练模型的时候,训练时候,内存十分平稳,预测的时候迅速增长,报内存不足的错误
原始是忘记加no_grad
解决方法:在预测的时候,加with torch.no_grad()
with torch.no_grad():
for i,batch in enumerate(test_loader):
pass
更多推荐
所有评论(0)