Skip to content

限定torch版本 #14

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

限定torch版本 #14

wants to merge 4 commits into from

Conversation

learningpro
Copy link

在使用torch==2.6.0的时候,运行inference_fireredasr_aed.sh 会报错,需要稍微降低一下版本

Traceback (most recent call last):
  File "/home/orange/FireRedASR/examples/fireredasr/speech2text.py", line 105, in <module>
    main(args)
  File "/home/orange/FireRedASR/examples/fireredasr/speech2text.py", line 43, in main
    model = FireRedAsr.from_pretrained(args.asr_type, args.model_dir)
  File "/home/orange/FireRedASR/examples/fireredasr/models/fireredasr.py", line 25, in from_pretrained
    model = load_fireredasr_aed_model(model_path)
  File "/home/orange/FireRedASR/examples/fireredasr/models/fireredasr.py", line 110, in load_fireredasr_aed_model
    package = torch.load(model_path, map_location=lambda storage, loc: storage)
  File "/home/orange/anaconda3/envs/fireredasr/lib/python3.10/site-packages/torch/serialization.py", line 1470, in load
    raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint. 
        (1) In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
        (2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message.
        WeightsUnpickler error: Unsupported global: GLOBAL argparse.Namespace was not an allowed global by default. Please use `torch.serialization.add_safe_globals([Namespace])` or the `torch.serialization.safe_globals([Namespace])` context manager to allowlist this global if you trust this class/function.

Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.

@wwfcnu
Copy link

wwfcnu commented Feb 12, 2025

设置 weights_only=False就可以了

@FireRedTeam
Copy link
Owner

Thanks for your pull request!

@FireRedTeam
Copy link
Owner

感谢PR。累积一段时间我们会统一处理,再次感谢。

@caoshiny
Copy link

微信图片_20250220144031
vim fireredasr/models/fireredasr.py

@YIQIHYM
Copy link

YIQIHYM commented May 20, 2025

TypeError: Unpickler.init() got an unexpected keyword argument 'weight_only'
出现新的错误

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.

5 participants