with torch.no_grad():
被包裹起來(lái)的上下文不走tracking,減少顯存的堆積占用
- torch.no_grad也可以作為注解的寫(xiě)法
@torch.no_grad()
def index():
清理顯存
torch.cuda.empty_cache()
添加詞句之后清理顯存。
with torch.no_grad():
被包裹起來(lái)的上下文不走tracking,減少顯存的堆積占用
@torch.no_grad()
def index():
torch.cuda.empty_cache()
添加詞句之后清理顯存。