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

RuntimeError: Cannot re-initialize CUDA in forked subprocess. #183

Open
pustar opened this issue Jul 6, 2022 · 1 comment
Open

RuntimeError: Cannot re-initialize CUDA in forked subprocess. #183

pustar opened this issue Jul 6, 2022 · 1 comment

Comments

@pustar
Copy link

pustar commented Jul 6, 2022

RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method

how to solve this problem?

an answer says: torch.multiprocessing.set_start_method('spawn')
but where to add this line?

@aryamazaheri
Copy link

In this line, you can change fork to either spawn or forkserver to make the code work.

mp_runner(single_proc_run, args=args, nprocs=num_proc, start_method="fork")

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