Open joetm opened 2 years ago
I've been trying to do the same! I'd love to be able to optionally make the process deterministic
Perhaps this?
Disabling the benchmarking feature with torch.backends.cudnn.benchmark = False causes cuDNN to deterministically select an algorithm, possibly at the cost of reduced performance.
This is all the code I added in an attempt to make the system (and its upscaler) deterministic.
from pytorch_lightning import seed_everything
seed = 1040790415
def seed_torch(seed = 1040790415):
os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":4096:8"
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
random.seed(seed)
np.random.seed(seed)
seed_everything(seed, workers=True)
torch.backends.cudnn.benchmark = False
torch.backends.cudnn.deterministic = True
torch.use_deterministic_algorithms(True, warn_only=True)
seed_torch()
If you set warn_only to False, it will show you the name of the nondeterministic algorithm. But there could be more.
In the end, I gave up and used another system entirely.
Hi, great work on this system!
I am looking for a way to make the image generation reproducible. Other notebooks/scripts have a seed value. I added some code to Latent Majesty Diffusion (v1.3) to seed torch:
I also added this snippet to seed pseudo-random number generators in pytorch, numpy, python.random:
But the images are still different in each run.
Any idea what else I need to change to make the image generation reproducible? That is, given the same seed, I want the system to produce the same image.