Skip to content

GPU memory leak in class ResBlock (line 44 & 46 in IFRNet_S.py) in pytorch 1.13.0 #32

@jsnzwu

Description

@jsnzwu

I found gpu memory leak when program runs into following lines. (It might be a bug in higher version of pytorch)

https://github.com/ltkong218/IFRNet/blob/main/models/IFRNet_S.py#L44
https://github.com/ltkong218/IFRNet/blob/main/models/IFRNet_S.py#L46

officical code (which leads to GPU memory leak):

out = self.conv1(x)
out[:, -self.side_channels:, :, :] = self.conv2(out[:, -self.side_channels:, :, :])
out = self.conv3(out)
out[:, -self.side_channels:, :, :] = self.conv4(out[:, -self.side_channels:, :, :])
out = self.prelu(x + self.conv5(out))
return out

then I changed codes to the following, GPU mem leak disappeared. (using concat to get a new feature after each side conv)

  out = self.conv1(x)
  side_ft = out[:, :-self.side_channels, :, :]
  conv_ft = out[:, -self.side_channels:, :, :]
  conv_ft = self.conv2(conv_ft)
  out = torch.cat([side_ft, conv_ft], axis=1)
  out = self.conv3(out)
  side_ft = out[:, :-self.side_channels, :, :]
  conv_ft = out[:, -self.side_channels:, :, :]
  conv_ft = self.conv4(conv_ft)
  out = torch.cat([side_ft, conv_ft], axis=1)
  out = self.prelu(x + self.conv5(out))

my specs:
ubuntu 20.04, python 3.9, pytorch1.13.1+cu117, with gpu v100(single card)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions