Trouble setting a manual seed

Possibly a silly question as I’m very much a noob, but I’m trying hard to learn. It’s my understanding that if you manually set a seed number, when printing the seed, it should not change. What am I missing here?

import torch

print(f"Version: {torch.__version__}")

generator = torch.Generator(device="cuda").manual_seed(30)
print(f"Seed 1: {generator.seed()}")
print(f"Seed 2: {generator.seed()}")

Version: 2.2.0+cu121
Seed 1: 1289450348342013
Seed 2: 2954870728471704

From the docs:

seed() → int
Gets a non-deterministic random number from std::random_device or the current time and uses it to seed a Generator.

If you want to access the internal state, use get_state().

You’re the man. Thank you and sorry for the dumb question.

It’s not a dumb question and you are welcome :slight_smile: