Solved by ptrblck in post #2 
              
              
                You could try to replace the indexing of input with input = torch.clamp(input, max=1), which might reduce the memory footprint. 
Let me know, if that helps.