You can use DataParallel or DistributedDataParallel for the multi-gpu config.
As for the OOM error, you need to split you data into batches anyway. Even if you manage to compute loss anyhow, you’ll get same error while trying to run loss backward()