How to Get the Same Random Numbers Every Run in PyTorch with torch.manual_seed
PyTorch draws new random numbers every time a script runs, which makes two runs hard to compare. Setting a seed makes the draws repeat exactly. This guide sets one with torch.manual_seed in PyTorch 2.15.0, on the CPU and on the GPU of an Apple M1 Pro.
