部署报错提示 module 'torch' has no attribute 'float32'
Open
Nobody has claimed this yet.
help wanted
- Dominant language
- Python
- Stars
- 12.3k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
严格按照 README 教程操作的,环境是 ananconda + python3.8,显卡是 A100 80G 版
依赖也是仓库中 requirements.txt 中的版本,但是运行到第三步的时候报错
Python 3.8.16 | packaged by conda-forge | (default, Feb 1 2023, 16:01:55)
[GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from transformers import AutoTokenizer, AutoModelForCausalLM
>>> tokenizer = AutoTokenizer.from_pretrained("fnlp/moss-moon-003-sft", trust_remote_code=True)
Explicitly passing a `revision` is encouraged when loading a model with custom code to ensure no malicious code has been contributed in a newer revision.
>>> model = AutoModelForCausalLM.from_pretrained("fnlp/moss-moon-003-sft", trust_remote_code=True).half().cuda()
Explicitly passing a `revision` is encouraged when loading a configuration with custom code to ensure no malicious code has been contributed in a newer revision.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/mnt/conda-envs/moss/lib/python3.8/site-packages/transformers/models/auto/auto_factory.py", line 441, in from_pretrained
config, kwargs = AutoConfig.from_pretrained(
File "/mnt/conda-envs/moss/lib/python3.8/site-packages/transformers/models/auto/configuration_auto.py", line 935, in from_pretrained
return config_class.from_pretrained(pretrained_model_name_or_path, **kwargs)
File "/mnt/conda-envs/moss/lib/python3.8/site-packages/transformers/configuration_utils.py", line 553, in from_pretrained
return cls.from_dict(config_dict, **kwargs)
File "/mnt/conda-envs/moss/lib/python3.8/site-packages/transformers/configuration_utils.py", line 696, in from_dict
config = cls(**config_dict)
File "/home/almalinux/.cache/huggingface/modules/transformers_modules/moss-moon-003-sft/configuration_moss.py", line 116, in __init__
super().__init__(
File "/mnt/conda-envs/moss/lib/python3.8/site-packages/transformers/configuration_utils.py", line 338, in __init__
self.torch_dtype = getattr(torch, self.torch_dtype)
AttributeError: module 'torch' has no attribute 'float32'
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the README's deployment tutorial and requirements.txt, reproducing the error at the third step in the reported Python 3.8 environment. Inspect the torch and transformers versions involved, then follow the traceback into configuration_moss.py. Done means the documented setup can load the model without the reported AttributeError, with the compatible dependency guidance captured in the relevant setup documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100