Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set random seed for a multi-GPU model #2516

Open
Galaxy-Husky opened this issue Nov 15, 2023 · 1 comment
Open

set random seed for a multi-GPU model #2516

Galaxy-Husky opened this issue Nov 15, 2023 · 1 comment

Comments

@Galaxy-Husky
Copy link

Hi,
I have a question about how to set seed when using multi gpus.

The following code snippet uses torch.cuda.manul_seed funciton.

if is_cuda and seed > 0:
        # These ensure same initialization in multi gpu mode
        torch.cuda.manual_seed(seed)

But I found a warning in the document of torch.cuda.manual_seed, which says "If you are working with a multi-GPU model, this function is insufficient to get determinism. To seed all GPUs, use manual_seed_all()."

Would it be better to change torch.cuda.manual_seed(seed) to torch.cuda.manual_seed_all(seed) ?

@vince62s
Copy link
Member

Thanks.
Have you tried to run twice the same run? not getting the same results in multi gpus ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants