You would have to lower the memory footprint e.g. by reducing the batch size during training or using a smaller model.
However, let’s first make sure you are not leaking memory.
Are you running out of memory in the first iteration or are you seeing an increase in the memory usage during training?
In the latter case, check if you are storing any tensors, which might still be attached to the computation graph.
E.g. storing the loss for printing purposes without detaching it, will increase the memory usage:
output = model(input)
loss = criterion(output, target)
losses.append(loss) # use losses.append(loss.detach())