Actually, the problem is not here at all. I tried the same function with two simple tensors, and I did not get any error:
>>> def rmse_loss(pred, targ):
...     denom = targ**2
...     denom = torch.sqrt(denom.sum()/len(denom))
...     return torch.sqrt(F.mse_loss(pred, targ))/denom
... 
 
>>> x = torch.tensor([1.0, 2.0, 3.0])
>>> x = x.to(device)

>>> y = torch.tensor([1.5, 2.2, 3.1])
>>> y = y.to(device)

>>> x.device
device(type='cuda', index=0)
>>> y.device
device(type='cuda', index=0)
>>> rmse_loss(x, y)
tensor(0.1340, device='cuda:0')