How to fix all random of training?

Hi,

I am training resnet18 with pytorch. I would like to do the following experiments:
step 1: trian resnet18.
step 2: train resnet18 again.
how to remove all random and use fixed in my code?

You can set the same random seed for both training process.

https://pytorch.org/docs/stable/notes/randomness.html

@techkang ,

in my code, I do:
`import random
random.seed(5)

torch.random.initial_seed()  
torch.cuda.manual_seed_all(5)

torch.cuda.manual_seed_all(5)
torch.backends.cudnn.deterministic=True
random.seed(5)
torch.random.initial_seed()  
torch.cuda.manual_seed_all(5)`

there is still something randomly changes sometimes. did I missed anything else?

or should I do the upper code in all related files? or I only need to do the upper code in the beginning of my project code?