-
Notifications
You must be signed in to change notification settings - Fork 584
fix: no pinning memory on CPU #4874
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
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.
Pull Request Overview
This PR fixes a PyTorch warning that occurs when pin_memory=True is set for DataLoader but the code is running on CPU, where pinned memory provides no benefit.
- Conditionally sets
pin_memorybased on device type to avoid unnecessary warnings - Maintains pinned memory optimization for GPU/accelerator usage while disabling it for CPU
for more information, see https://pre-commit.ci
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughThe update changes the behavior of the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (30)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## devel #4874 +/- ##
==========================================
- Coverage 84.76% 84.71% -0.06%
==========================================
Files 699 699
Lines 68077 68128 +51
Branches 3541 3542 +1
==========================================
+ Hits 57708 57716 +8
- Misses 9235 9277 +42
- Partials 1134 1135 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Avoid specifying pin_memory for test DataLoaders to eliminate warnings when no accelerator is available. #4874 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Updated test configurations to rely on default memory pinning behavior in data loading, improving compatibility across environments. * Simplified test setup parameters to reduce potential flakiness and align with framework defaults. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This PR fixes the warning message when running on CPU: ``` torch/utils/data/dataloader.py:665: UserWarning: 'pin_memory' argument is set as true but no accelerator is found, then device pinned memory won't be used. warnings.warn(warn_msg) ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved memory handling by enabling memory pinning only when using non-CPU devices, which may enhance performance and stability when training on GPUs. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Avoid specifying pin_memory for test DataLoaders to eliminate warnings when no accelerator is available. deepmodeling#4874 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Updated test configurations to rely on default memory pinning behavior in data loading, improving compatibility across environments. * Simplified test setup parameters to reduce potential flakiness and align with framework defaults. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This PR fixes the warning message when running on CPU:
Summary by CodeRabbit