baichuan-inc / Baichuan2

A series of large language models developed by Baichuan Intelligent Technology
https://huggingface.co/baichuan-inc
Apache License 2.0
4.08k stars 293 forks source link

streamlit运行cli_demo 遇到TypeError: _set_gradient_checkpointing() got an unexpected keyword argument 'enable' #251

Open wrl1224 opened 11 months ago

wrl1224 commented 11 months ago

Traceback (most recent call last): File "E:\wrl\PythonCode\Baichuan2\venv\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 534, in _run_script exec(code, module.dict) File "E:\wrl\PythonCode\Baichuan2\cli_demo.py", line 7, in from transformers import AutoModelForCausalLM, AutoTokenizer ImportError: cannot import name 'AutoModelForCausalLM' from 'transformers' (E:\wrl\PythonCode\Baichuan2\venv\lib\site-packages\transformers__init.py) init model ... Xformers is not installed correctly. If you want to use memory_efficient_attention to accelerate training use the following command to install Xformers pip install xformers. 2023-11-03 18:34:41.839 Uncaught app exception Traceback (most recent call last): File "E:\wrl\PythonCode\Baichuan2\venv\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 534, in _run_script exec(code, module.dict) File "E:\wrl\PythonCode\Baichuan2\cli_demo.py", line 91, in main() File "E:\wrl\PythonCode\Baichuan2\cli_demo.py", line 52, in main model, tokenizer = init_model() File "E:\wrl\PythonCode\Baichuan2\cli_demo.py", line 13, in init_model model = AutoModelForCausalLM.from_pretrained( File "E:\wrl\PythonCode\Baichuan2\venv\lib\site-packages\transformers\models\auto\auto_factory.py", line 561, in from_pretrained return model_class.from_pretrained( File "C:\Users\Administrator/.cache\huggingface\modules\transformers_modules\Baichuan2-13B-Chat\modeling_baichuan.py", line 670, in from_pretrained return super(BaichuanForCausalLM, cls).from_pretrained(pretrained_model_name_or_path, model_args, File "E:\wrl\PythonCode\Baichuan2\venv\lib\site-packages\transformers\modeling_utils.py", line 3236, in from_pretrained model = cls(config, model_args, **model_kwargs) File "C:\Users\Administrator/.cache\huggingface\modules\transformers_modules\Baichuan2-13B-Chat\modeling_baichuan.py", line 539, in init self.model = BaichuanModel(config) File "C:\Users\Administrator/.cache\huggingface\modules\transformers_modules\Baichuan2-13B-Chat\modeling_baichuan.py", line 305, in init self.post_init() File "E:\wrl\PythonCode\Baichuan2\venv\lib\site-packages\transformers\modeling_utils.py", line 1159, in post_init self._backward_compatibility_gradient_checkpointing() File "E:\wrl\PythonCode\Baichuan2\venv\lib\site-packages\transformers\modeling_utils.py", line 1163, in _backward_compatibility_gradient_checkpointing self.gradient_checkpointing_enable() File "E:\wrl\PythonCode\Baichuan2\venv\lib\site-packages\transformers\modeling_utils.py", line 1872, in gradient_checkpointing_enable self._set_gradient_checkpointing(enable=True, gradient_checkpointing_func=gradient_checkpointing_func) TypeError: _set_gradient_checkpointing() got an unexpected keyword argument 'enable' init model ... 2023-11-03 18:34:46.606 Uncaught app exception Traceback (most recent call last): File "E:\wrl\PythonCode\Baichuan2\venv\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 534, in _run_script exec(code, module.dict__) File "E:\wrl\PythonCode\Baichuan2\cli_demo.py", line 91, in main() File "E:\wrl\PythonCode\Baichuan2\cli_demo.py", line 52, in main model, tokenizer = init_model() File "E:\wrl\PythonCode\Baichuan2\cli_demo.py", line 13, in init_model model = AutoModelForCausalLM.from_pretrained( File "E:\wrl\PythonCode\Baichuan2\venv\lib\site-packages\transformers\models\auto\auto_factory.py", line 561, in from_pretrained return model_class.from_pretrained( File "C:\Users\Administrator/.cache\huggingface\modules\transformers_modules\Baichuan2-13B-Chat\modeling_baichuan.py", line 670, in from_pretrained return super(BaichuanForCausalLM, cls).from_pretrained(pretrained_model_name_or_path, model_args, File "E:\wrl\PythonCode\Baichuan2\venv\lib\site-packages\transformers\modeling_utils.py", line 3236, in from_pretrained model = cls(config, model_args, **model_kwargs) File "C:\Users\Administrator/.cache\huggingface\modules\transformers_modules\Baichuan2-13B-Chat\modeling_baichuan.py", line 539, in init self.model = BaichuanModel(config) File "C:\Users\Administrator/.cache\huggingface\modules\transformers_modules\Baichuan2-13B-Chat\modeling_baichuan.py", line 305, in init self.post_init() File "E:\wrl\PythonCode\Baichuan2\venv\lib\site-packages\transformers\modeling_utils.py", line 1159, in post_init self._backward_compatibility_gradient_checkpointing() File "E:\wrl\PythonCode\Baichuan2\venv\lib\site-packages\transformers\modeling_utils.py", line 1163, in _backward_compatibility_gradient_checkpointing self.gradient_checkpointing_enable() File "E:\wrl\PythonCode\Baichuan2\venv\lib\site-packages\transformers\modeling_utils.py", line 1872, in gradient_checkpointing_enable self._set_gradient_checkpointing(enable=True, gradient_checkpointing_func=gradient_checkpointing_func) TypeError: _set_gradient_checkpointing() got an unexpected keyword argument 'enable'

wrl1224 commented 11 months ago

遇到这个问题不知道怎么解决,需要帮助。

newfyu commented 11 months ago

同样问题, 降级transformers==4.33.1 and tokenizers==0.13.3

SevenMpp commented 11 months ago

请问您这个问题解决了吗??

newfyu commented 11 months ago

就按我说的版本降级就可以了

2023年11月7日 18:14,SevenMpp @.***> 写道:

请问您这个问题解决了吗??

— Reply to this email directly, view it on GitHub https://github.com/baichuan-inc/Baichuan2/issues/251#issuecomment-1798206992, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKJ2EPSRJXMT3WAAPXBILHTYDIC2HAVCNFSM6AAAAAA64HIWBSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJYGIYDMOJZGI. You are receiving this because you commented.

Zhu-DaBao commented 10 months ago

同样问题, 降级transformers==4.33.1 and tokenizers==0.13.3 问题:TypeError: _set_gradient_checkpointing() got an unexpected keyword argument 'enable' 感谢大佬,实测有用,这个问题困扰了我好几天 运行下面代码就可以降级了 pip install transformers==4.33.1 pip install tokenizers==0.13.3