There is a slight improvement in terms of time. I single out the part of the code that trains generator as shown below.
label = torch.full((batch_size,), real_label, device=device)

def train():
    netG.zero_grad()
    noise = torch.randn(batch_size, nz, 1, 1, device=device)
    fake = netG(noise)
    output = netD(fake).view(-1)
    errG = criterion(output, label)
    errG.backward()
    optimizerG.step()
    
%timeit train()
# -> 44.3 ms ± 1.5 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
for p in netD.parameters():
    temp.requires_grad_(False)


%timeit train()
# -> 41 ms ± 253 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)