-
Notifications
You must be signed in to change notification settings - Fork 24.3k
initialize device when pinning memory on this device, short circuit i… #145752
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
Conversation
…s_pinned if device is not initialized
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/145752
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit ad816b7 with merge base 30dea84 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM !
Co-authored-by: albanD <albandes@fb.com>
Hm no this actually initializes context on the 0th device (I think it shouldn't have, but I'll have to check)
so won't work as is |
The behavior above is caused by pinning itself, not by initializing context, so this diff is a strict improvement over existing state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
The merge job was canceled or timed out. This most often happen if two merge requests were issued for the same PR, or if merge job was waiting for more than 6 hours for tests to finish. In later case, please do not hesitate to reissue the merge command |
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
pytorch#145752) …s_pinned if device is not initialized Do not land RFC potential fix for pytorch#144687 Now `.is_pinned(device="cuda")` does not initialize device and thus doesn't poison the fork (but it complains about `device` arg being deprecated). To not need `device=` arg we'd need to fix get_accelerator to not initialize device. Pull Request resolved: pytorch#145752 Approved by: https://github.com/albanD Co-authored-by: albanD <albandes@fb.com>
PR pytorch#145752 has added a check in the isPinnedPtr to check if a device is initialized before checking if the tensor is pinned. Also that PR has added a lazy initialization trigger when an at::empty is called with a pinned param set to true. However, when the tensor is firstly created and it is pinned in a separate call by calling pin_memory() function, lazy device init is not called so is_pinned returns always false. With this PR, the lazy initialization is moved to getPinnedMemoryAllocator function, thus it is assured that device is initialized before we pin a tensor.
PR pytorch#145752 has added a check in the isPinnedPtr to check if a device is initialized before checking if the tensor is pinned. Also that PR has added a lazy initialization trigger when an at::empty is called with a pinned param set to true. However, when the tensor is firstly created and it is pinned in a separate call by calling pin_memory() function, lazy device init is not called so is_pinned returns always false. With this PR, the lazy initialization is moved to getPinnedMemoryAllocator function, thus it is assured that device is initialized before we pin a tensor.
…itialization. (#149033) PR #145752 has added a check in the isPinnedPtr to check if a device is initialized before checking if the tensor is pinned. Also that PR has added a lazy initialization trigger when an at::empty is called with a pinned param set to true. However, when the tensor is firstly created and it is pinned in a separate call by calling pin_memory() function, lazy device init is not called so is_pinned returns always false. With this PR, the lazy initialization is moved to getPinnedMemoryAllocator function, thus it is assured that device is initialized before we pin a tensor. Fixes #149032 @ngimel @albanD Pull Request resolved: #149033 Approved by: https://github.com/ngimel, https://github.com/albanD
…itialization. (#149033) PR #145752 has added a check in the isPinnedPtr to check if a device is initialized before checking if the tensor is pinned. Also that PR has added a lazy initialization trigger when an at::empty is called with a pinned param set to true. However, when the tensor is firstly created and it is pinned in a separate call by calling pin_memory() function, lazy device init is not called so is_pinned returns always false. With this PR, the lazy initialization is moved to getPinnedMemoryAllocator function, thus it is assured that device is initialized before we pin a tensor. Fixes #149032 @ngimel @albanD Pull Request resolved: #149033 Approved by: https://github.com/ngimel, https://github.com/albanD (cherry picked from commit 420a9be)
…itialization. (#149183) [regression] Fix pin_memory() when it is called before device lazy initialization. (#149033) PR #145752 has added a check in the isPinnedPtr to check if a device is initialized before checking if the tensor is pinned. Also that PR has added a lazy initialization trigger when an at::empty is called with a pinned param set to true. However, when the tensor is firstly created and it is pinned in a separate call by calling pin_mem 7715 ory() function, lazy device init is not called so is_pinned returns always false. With this PR, the lazy initialization is moved to getPinnedMemoryAllocator function, thus it is assured that device is initialized before we pin a tensor. Fixes #149032 @ngimel @albanD Pull Request resolved: #149033 Approved by: https://github.com/ngimel, https://github.com/albanD (cherry picked from commit 420a9be) Co-authored-by: Bartlomiej Stemborowski <bstemborowskix@habana.ai>
…s_pinned if device is not initialized
Do not land
RFC
potential fix for #144687
Now
.is_pinned(device="cuda")
does not initialize device and thus doesn't poison the fork (but it complains aboutdevice
arg being deprecated). To not needdevice=
arg we'd need to fix get_accelerator to not initialize device.cc @malfet, @albanD