I wrap blocks of the models into a checkpoint . according to the tutorial,But crazy error report.
my code:
def conv_lrelu(in_ch, out_ch, ker_sz, pad):
    return nn.Sequential(nn.Conv2d(in_ch, out_ch, ker_sz, padding=pad, bias=False),
                         nn.LeakyReLU())
def seg1(self, x):
      x = self.layer1(x)
      x = self.maxpool(x)
      return x
def fc(self, x):
      x = self.dropout(x)
      x = x.view(x.size(0), 512 * 12 * 5)
      x = F.leaky_relu(self.fc1(x))
      x = F.leaky_relu(self.fc2(x))
      x = x.view(x.size(0),-1, int(self.image_size[0]/2), int(self.image_size[1]/2))
def EDSR(self,x):
      x = self.res1(x)
      out = self.res2(x)
      out = self.res3(out)
      out = out + x
      out = self.res4(out)
      out = self.shuffle(out)
      out = self.res5(out)
      out = np.squeeze(out)
      return out
x = checkpoint(self.seg1, x)
x = checkpoint(self.seg2, x)
x = checkpoint(self.seg3, x)
x = checkpoint(self.seg4, x)
x = checkpoint(self.seg5, x)
x = checkpoint(self.fc, x)
out = checkpoint(self.EDSR, x)

In addition, no matter how I adjust the batchsize, there will always be CUDA out of memory.But I have memory 32G.And the program can run normally on this computer before, there will be no CUDA out of memory problem。I really don’t know what went wrong, why it worked well before and now it can’t run。