I’ve tried your code with print(torch.cuda.memory_allocated()) instead of your nvml functions, since I’m not familiar with them.
It seems the code uses approx. 82MB:
class Test(nn.Module):
    def __init__(self):
        super(Test, self).__init__()

    def forward(self, x):
        print(torch.cuda.memory_allocated() / 1024**2)
        output = F.dropout(x, training=True)
        print(torch.cuda.memory_allocated() / 1024**2)
        return output


def run():
  for i in range(1,2):
    x = torch.rand(30, 175, 4096).to(device)
    out = model(x)


device = torch.device('cuda')
model = Test().to(device)

run()
> 165
> 247