Skip to content
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

Use weights_only for loading #3427

Merged
merged 2 commits into from
Aug 3, 2024
Merged

Use weights_only for loading #3427

merged 2 commits into from
Aug 3, 2024

Conversation

kit1980
Copy link
Contributor

@kit1980 kit1980 commented Aug 2, 2024

torch.load without weights_only parameter is unsafe. Explicitly set weights_only to False only if you trust the data you load and full pickle functionality is needed, otherwise set weights_only=True.

If weights_only=True doesn't work for some cases, then explicit weights_only=False should be used.

Found with https://github.com/pytorch-labs/torchfix/

@kit1980 kit1980 requested a review from mashb1t as a code owner August 2, 2024 23:49
@mashb1t
Copy link
Collaborator

mashb1t commented Aug 3, 2024

Thanks for your contribution and the hint.

Relates to

From https://pytorch.org/docs/stable/generated/torch.load.html:

Warning
torch.load() unless weights_only parameter is set to True, uses pickle module implicitly, which is known to be insecure. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling. Never load data that could have come from an untrusted source in an unsafe mode, or that could have been tampered with. Only load data you trust.

@mashb1t mashb1t changed the base branch from main to develop August 3, 2024 10:32
@mashb1t mashb1t merged commit da3d4d0 into lllyasviel:develop Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants