YonghaoXu/SACNet代码写的非常清晰,我在跑的时候,由于GPU显存问题,总是out of memory
查询了解决方案,直接上代码:
第一处:
output = Model(processed_image)
修改为:
with torch.no_grad():
try:
output = Model(processed_image)
except RuntimeError as exception:
if "out of memory" in str(exception):
print("warning: out of memory!")
if hasattr(torch.cuda, 'empty_cache'):
torch.cuda.empty_cache()
else:
raise exception
第二处:
output = Model(adv_images)
修改为: