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

运行webdemo2的时候出现ModuleNotFoundError: No module named 'transformers_modules.' #8

Closed
starkgao opened this issue Oct 27, 2023 · 4 comments

Comments

@starkgao
Copy link

starkgao commented Oct 27, 2023

File "G:\ai\ChatGLM\ChatGLM3\web_demo2.py", line 23, in
tokenizer, model = get_model()
File "G:\ai\ChatGLM\ChatGLM3\venv\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 212, in wrapper
return cached_func(*args, **kwargs)
File "G:\ai\ChatGLM\ChatGLM3\venv\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 241, in call
return self._get_or_create_cached_value(args, kwargs)
File "G:\ai\ChatGLM\ChatGLM3\venv\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 267, in _get_or_create_cached_value
return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)
File "G:\ai\ChatGLM\ChatGLM3\venv\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 321, in _handle_cache_miss
computed_value = self.info.func(*func_args, **func_kwargs)
File "G:\ai\ChatGLM\ChatGLM3\web_demo2.py", line 14, in get_model
tokenizer = AutoTokenizer.from_pretrained("./models/chatglm3-6b", trust_remote_code=True)
File "G:\ai\ChatGLM\ChatGLM3\venv\lib\site-packages\transformers\models\auto\tokenization_auto.py", line 676, in from_pretrained
tokenizer_class = get_class_from_dynamic_module(class_ref, pretrained_model_name_or_path, **kwargs)
File "G:\ai\ChatGLM\ChatGLM3\venv\lib\site-packages\transformers\dynamic_module_utils.py", line 443, in get_class_from_dynamic_module
return get_class_in_module(class_name, final_module.replace(".py", ""))
File "G:\ai\ChatGLM\ChatGLM3\venv\lib\site-packages\transformers\dynamic_module_utils.py", line 164, in get_class_in_module
module = importlib.import_module(module_path)
File "D:\Program Files\python\lib\importlib_init
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 992, in _find_and_load_unlocked
File "", line 241, in _call_with_frames_removed
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 992, in _find_and_load_unlocked
File "", line 241, in _call_with_frames_removed
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'transformers_modules.'
但实际transformers已经安装也是4.30.2

@jediwolf
Copy link

升级transformers到最新,问题解决,4.30.2根本不能用

@jeremysong88
Copy link

@jediwolf 👍 描述正确,我将transformers升级到 transformers==4.34.1 后运行正常

@WWeellkkiinn
Copy link

@jediwolf 完全正确,使用pip install --upgrade transformers更新后完美解决问题

@zhangch9 zhangch9 closed this as completed Nov 6, 2023
@changzheng169
Copy link

@WWeellkkiinn 为什么我将transformers升级到最新后还是不能用
Successfully installed huggingface-hub-0.20.1 tokenizers-0.15.0 transformers-4.36.2
(chatglm3) star@star-S8030GM2NE:~/ChatGLM3/basic_demo$ streamlit run web_demo_streamlit.py

2023-12-20 21:45:07.062 Uncaught app exception
Traceback (most recent call last):
File "/home/star/.local/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script
exec(code, module.dict)
File "/home/star/ChatGLM3/basic_demo/web_demo_streamlit.py", line 16, in
from transformers import AutoModel, AutoTokenizer
ModuleNotFoundError: No module named 'transformers'

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

6 participants