you are right.it seems that I didn’t  Release memory. how should I do to release them?
here is my training code
‘’
for i in range(args.epochs):
    scheduler.step(i)

    for j,(data,label) in enumerate(train_dl,0):
        model.train()
        model.zero_grad()
        optimizer.zero_grad()
        if args.use_gpu:
            data = data.cuda()
            label = label.cuda()
            
        pred,_ = model(data)
        loss =1e3*criterion(pred,label)
        
        loss.backward()
        optimizer.step()
#        optimizer.zero_grad()
        
        # training curve plot
        print("[epoch %d step %d loss %.4f]"%(i,j,loss.item()))
        if j%10==0:
            writer.add_scalar('loss', loss.item(),j)
    model.eval()
    x_val,_ = model(x_test)
    val_loss = criterion(x_val ,y_test)
    writer.add_scalar('val_loss', val_loss,i)
    if i%50==0:
        # if y_test.dim() == 4 and y_test.size(1)==1:
        #     y_test = torch.cat((y_test,y_test,y_test),dim=1)
        #     x_val = torch.cat((x_val,x_val,x_val),dim=1)
        #     x_test = torch.cat((x_test,x_test,x_test),dim=1)
    
        clean_grid = torchvision.utils.make_grid(y_test,nrow=16)
        writer.add_image('clean image',clean_grid,dataformats='CHW')
        dirty_grid = torchvision.utils.make_grid(x_test,nrow=16)
        writer.add_image('dirty image',dirty_grid,dataformats='CHW')
        debackground_grid = torchvision.utils.make_grid(x_val,nrow=16)
        writer.add_image('debackground image',debackground_grid,dataformats='CHW')
    print("[epoch %d val_loss %.4f]"%(i,val_loss))
        
    if i%10==0:
        path = os.path.join(os.getcwd(),'model','deback_epoch%d.pth'%(i+1))
        torch.save(model.state_dict(),path)

‘’’