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

Bug using FutureWarning: You are using torch.load with weights_only=False #439

Open
VladIPlay opened this issue Aug 23, 2024 · 3 comments
Open

Comments

@VladIPlay
Copy link

This FutureWarning appears to be new in torch 2.4.0

.venv\Lib\site-packages\stanza\models\tokenize\trainer.py:85: FutureWarning: You are using torch.loadwithweights_only=False(the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value forweights_onlywill be flipped toTrue. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals. We recommend you start setting weights_only=Truefor any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature. checkpoint = torch.load(filename, lambda storage, loc: storage)

@solar-sprout
Copy link

solar-sprout commented Sep 10, 2024

This is not ideal, but if you just want to suppress the warning so you can focus on more important messages, this worked for me:

# Suppress stanza/pytorch warnings
import warnings
warnings.filterwarnings("ignore", category=FutureWarning, module="stanza")

@janpeterka
Copy link

Can I suppress warnings when calling from cmd like argos-translate --from cs --to en "..."?

@autotunafish
Copy link

autotunafish commented Dec 21, 2024

@janpeterka Add those lines to the argos-translate bin file, before 'cli.main()'. Mine lives in the '/home/me/.local/bin/' directory (after having followed normal pip installation). Just copypasta those lines into the file and save. It'll look something like this when its good:

#!/usr/bin/python3

from argostranslate import cli
#Suppress stanza/pytorch warnings
import warnings
warnings.filterwarnings("ignore", category=FutureWarning, module="stanza")

cli.main()

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

No branches or pull requests

4 participants