Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[torch][cuda] fix race condition in cuda initialization (pytorch#143238)
The access to lazy init callbacks (`_lazy_seed_tracker` and `_queued_calls`) is not synchronized with the initialization lock. This exposes us to the following race: 1. start `_lazy_init` 2. take `_initialization_lock` 3. flush `_queued_calls` and run them all 4. another thread comes in and uses `_lazy_call` to put something on the queue (in our case, the `manual_seed`) 5. original thread finishes initializing, but never runs that call Pull Request resolved: pytorch#143238 Approved by: https://github.com/ngimel
- Loading branch information