The error indicates that your GPU is running out of memory, so you would have to e.g. reduce the batch size of the input, lower the memory usage by using a smaller model, or e.g. use torch.utils.checkpoint to trade compute for memory.