FireRedASR icon indicating copy to clipboard operation
FireRedASR copied to clipboard

限定torch版本

Open learningpro opened this issue 10 months ago • 5 comments

在使用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.

learningpro avatar Feb 11 '25 09:02 learningpro

设置 weights_only=False就可以了

wwfcnu avatar Feb 12 '25 07:02 wwfcnu

Thanks for your pull request!

FireRedTeam avatar Feb 13 '25 04:02 FireRedTeam

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

FireRedTeam avatar Feb 14 '25 02:02 FireRedTeam

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

caoshiny avatar Feb 20 '25 06:02 caoshiny

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

slowym avatar May 20 '25 06:05 slowym