Does the order of execution of 'net.cuda()' and 'net.load_state_dict' affect the result?

Hi, I am confused about the order of execution of ‘net.cuda()’ and ‘net.load_state_dict’.
Will the following two execution orders produce the same result?

# method 1
net = model(args)
net.cuda()
net.load_state_dict(checkpoints)

# method 2
net = model(args)
net.load_state_dict(checkpoints)
net.cuda()
1 Like

I never tried but I think they should produce the same results.

I generally load the state dict first and then send model to cuda device. As shown here in the documentation.

Thanks for your share!