-
Notifications
You must be signed in to change notification settings - Fork 24.3k
pickle.loads
throws warning with nn.Module
#130242
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
Comments
I believe the root cause is that
8000
Line 1206 in 16d53cb
Lines 504 to 505 in 16d53cb
Since |
Fixes pytorch#130242 Since `torch.save` does not use pickle for storages, the `torch.load` in `_load_from_bytes` should not ever be called when `torch.load`-ing a checkpoint. Setting weights_only=False explicitly in `_load_from_bytes` to avoid the weights_only warning when using the pickle module Pull Request resolved: pytorch#130246 Approved by: https://github.com/albanD
Fixes #130242 Since `torch.save` does not use pickle for storages, the `torch.load` in `_load_from_bytes` should not ever be called when `torch.load`-ing a checkpoint. Setting weights_only=False explicitly in `_load_from_bytes` to avoid the weights_only warning when using the pickle module Pull Request resolved: #130246 Approved by: https://github.com/albanD (cherry picked from commit dfd1d19)
Fix warning when pickle.load torch.Storage (#130246) Fixes #130242 Since `torch.save` does not use pickle for storages, the `torch.load` in `_load_from_bytes` should not ever be called when `torch.load`-ing a checkpoint. Setting weights_only=False explicitly in `_load_from_bytes` to avoid the weights_only warning when using the pickle module Pull Request resolved: #130246 Approved by: https://github.com/albanD (cherry picked from commit dfd1d19) Co-authored-by: Mikayla Gawarecki <mikaylagawarecki@gmail.com>
Validated the fix by running:
But with 2.4.1:
|
Uh oh!
There was an error while loading. Please reload this page.
Pickling a
nn.Module
that contains tensor attributes now throws a warning:This seems to be due to #129239 (CC-ing authors and reviewers: @mikaylagawarecki @albanD @malfet).
What is the recommended workaround to avoid the warning? The current warning message is unfortunately unactionable in this case because the user didn't call
torch.load()
directly, onlypickle.loads()
.Note: this is related to / causing pytorch/vision#8517
torch version:
2.5.0.dev20240708+cpu
cc @mruberry @mikaylagawarecki
The text was updated successfully, but these errors were encountered: