GPU is free, model is running fine with MSELoss(), here is the function where i am calling the dice loss.
def train_g(optimizer,fake_data,real_data):
    N=28*28*512
    optimizer.zero_grad()
    predict=d(fake_data)
    error=loss(predict,one_target(N).type(dtype)) +dice_loss(fake_data.view(-1,1),real_data.view(-1,1))
    error.backward()
    optimizer.step()
    return error