Solved by ptrblck in post #2 
              
              
                Could you post an executable code snippet to reproduce this issue? 
Using the forward method and removing undefined parts of the code does not result in a memory leak: 
class MyModel(nn.Module):
    def __init__(self):
        super(MyModel, self).__init__()
        self.shared_gen_linear = nn.Linea…