-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Memory snapshots from C++ #86190
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
Memory snapshots from C++ #86190
Conversation
Sometimes the driving process want to save memory snapshots but isn't Python. Add a simple API to turn it on without python stack traces. It still saves to the same format for the vizualization and summary scripts, using the C++ Pickler. [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/86190
Note: Links to docs will display an error until the docs builds have been completed. ✅ No Failures, 2 PendingAs of commit 871d880: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Sometimes the driving process want to save memory snapshots but isn't Python. Add a simple API to turn it on without python stack traces. It still saves to the same format for the vizualization and summary scripts, using the C++ Pickler. [ghstack-poisoned]
Sometimes the driving process want to save memory snapshots but isn't Python. Add a simple API to turn it on without python stack traces. It still saves to the same format for the vizualization and summary scripts, using the C++ Pickler. [ghstack-poisoned]
| std::unordered_map<std::string, uint32_t> memoized_globals_map_; | ||
| std::unordered_map<std::string, uint32_t> memoized_strings_map_; | ||
| std::unordered_map<std::string, uint32_t> memoized_devices_map_; | ||
| bool tag_aggregates_; |
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.
not sure what this field is doing
| try: | ||
| m.record(True) | ||
| t = torch.rand(311, 411, device='cuda') | ||
| mem = pickle.loads(m.do_snapshot()) |
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.
nice
torch/csrc/cuda/memory_snapshot.cpp
Outdated
| enabled ? blank_context : nullptr); | ||
| } | ||
|
|
||
| std::vector<char> _memory_snapshot_pickled() { |
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.
going into a vector is kinda weird but OK
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.
A std::string instead? I don't want it to be a file because these things might need to be written via API calls rather than directly to a file.
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.
going to a file stream would be the normal thing, but I think this is fine, we can reevaluate if this ends up being too big to store in memory (it shouldn't ever, tbh)
Sometimes the driving process want to save memory snapshots but isn't Python. Add a simple API to turn it on without python stack traces. It still saves to the same format for the vizualization and summary scripts, using the C++ Pickler. [ghstack-poisoned]
Sometimes the driving process want to save memory snapshots but isn't Python. Add a simple API to turn it on without python stack traces. It still saves to the same format for the vizualization and summary scripts, using the C++ Pickler. [ghstack-poisoned]
Sometimes the driving process want to save memory snapshots but isn't Python. Add a simple API to turn it on without python stack traces. It still saves to the same format for the vizualization and summary scripts, using the C++ Pickler. [ghstack-poisoned]
|
@pytorchbot merge |
|
@pytorchbot successfully started a merge job. Check the current status here. |
|
Hey @zdevito. |
Summary: Sometimes the driving process want to save memory snapshots but isn't Python. Add a simple API to turn it on without python stack traces. It still saves to the same format for the vizualization and summary scripts, using the C++ Pickler. Pull Request resolved: #86190 Approved by: https://github.com/ezyang Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/736adc08084814c13d57324f74adad091e304eb2 Reviewed By: seemethere Differential Revision: D40106329 fbshipit-source-id: 37912dc751d7e51cdcd0724623a9dde2617e4841
Stack from ghstack (oldest at bottom):
Sometimes the driving process want to save memory snapshots but isn't Python.
Add a simple API to turn it on without python stack traces. It still
saves to the same format for the vizualization and summary scripts, using
the C++ Pickler.