Skip to content

Fix: Update torch.load to use weights_only=True to prevent security w… #2451

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yaslack
Copy link

@yaslack yaslack commented Nov 20, 2024

Fix: Update torch.load to use weights_only=True to prevent security warning

Changes Made:

In this pull request, I updated the torch.load function call to use weights_only=True in order to prevent a security warning related to the unpickling process.

Code Change:

- checkpoint = torch.load(fp, map_location=device)
+ checkpoint = torch.load(fp, map_location=device, weights_only=True)

@bitplane
Copy link

bitplane commented Dec 4, 2024

For anyone else with this issue, I've been doing this for now:

import functools
whisper.torch.load = functools.partial(whisper.torch.load, weights_only=True)

Copy link

@hamirmahal hamirmahal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jongwook this seems like a useful change that would reduce a lot of noise for developers.

Are you open to it?

@bitplane
Copy link

For anyone else with this issue, I've been doing this for now:

import functools
whisper.torch.load = functools.partial(whisper.torch.load, weights_only=True)

This was happening in other things too, so I ended up making a module for it. Trivial, but I found it useful so thought I'd share:

https://github.com/bitplane/torch_weightsonly

@oscardssmith
Copy link

any updates here? this seems like an improvement that should be merged

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants