Hi,
Do you actually need all the outputs at the same time?
If so, you can try the checkpoint module to reduce the memory usage to only one branch at a time: torch.utils.checkpoint — PyTorch 1.8.0 documentation 1