No problem.
To clarify, it’s because gdl_loss contains weights (torch.nn.Parameter), so you need to load them into GPU by calling to(device) before interacting them with inputs that are in GPU memory, just like what you did to net.
If you are using losses that does not define new weights, you don’t need to do so.