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

Failed to import transformers.models.qwen2_vl.modeling_qwen2_vl #68

Closed
RemSynch opened this issue Sep 2, 2024 · 2 comments
Closed

Failed to import transformers.models.qwen2_vl.modeling_qwen2_vl #68

RemSynch opened this issue Sep 2, 2024 · 2 comments

Comments

@RemSynch
Copy link

RemSynch commented Sep 2, 2024

2080ti,Python3.11,transformers 4.45.0.dev0

在运行了:
pip install git+https://github.com/huggingface/transformers accelerate
pip install qwen-vl-utils
后尝试运行示例代码时报错:

RuntimeError: Failed to import transformers.models.qwen2_vl.modeling_qwen2_vl because of the following error (look up to see its traceback):
Failed to import transformers.generation.utils because of the following error (look up to see its traceback):
module 'torch.nn' has no attribute 'RMSNorm'

依赖安装都是成功的代码无爆红:
image

完整错误信息:

Traceback (most recent call last):
  File "D:\A_MyCodingWorkSpace\environment\Anaconda3\Anaconda\envs\qwen2_vl\Lib\site-packages\transformers\utils\import_utils.py", line 1659, in _get_module
    return importlib.import_module("." + module_name, self.__name__)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\A_MyCodingWorkSpace\environment\Anaconda3\Anaconda\envs\qwen2_vl\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "D:\A_MyCodingWorkSpace\environment\Anaconda3\Anaconda\envs\qwen2_vl\Lib\site-packages\transformers\generation\utils.py", line 51, in <module>
    from ..pytorch_utils import isin_mps_friendly
  File "D:\A_MyCodingWorkSpace\environment\Anaconda3\Anaconda\envs\qwen2_vl\Lib\site-packages\transformers\pytorch_utils.py", line 27, in <module>
    ALL_LAYERNORM_LAYERS = [nn.LayerNorm, nn.RMSNorm]
                                          ^^^^^^^^^^
AttributeError: module 'torch.nn' has no attribute 'RMSNorm'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\A_MyCodingWorkSpace\environment\Anaconda3\Anaconda\envs\qwen2_vl\Lib\site-packages\transformers\utils\import_utils.py", line 1659, in _get_module
    return importlib.import_module("." + module_name, self.__name__)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\A_MyCodingWorkSpace\environment\Anaconda3\Anaconda\envs\qwen2_vl\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "D:\A_MyCodingWorkSpace\environment\Anaconda3\Anaconda\envs\qwen2_vl\Lib\site-packages\transformers\models\qwen2_vl\modeling_qwen2_vl.py", line 41, in <module>
    from ...modeling_utils import PreTrainedModel
  File "D:\A_MyCodingWorkSpace\environment\Anaconda3\Anaconda\envs\qwen2_vl\Lib\site-packages\transformers\modeling_utils.py", line 46, in <module>
    from .generation import GenerationConfig, GenerationMixin
  File "<frozen importlib._bootstrap>", line 1229, in _handle_fromlist
  File "D:\A_MyCodingWorkSpace\environment\Anaconda3\Anaconda\envs\qwen2_vl\Lib\site-packages\transformers\utils\import_utils.py", line 1649, in __getattr__
    module = self._get_module(self._class_to_module[name])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\A_MyCodingWorkSpace\environment\Anaconda3\Anaconda\envs\qwen2_vl\Lib\site-packages\transformers\utils\import_utils.py", line 1661, in _get_module
    raise RuntimeError(
RuntimeError: Failed to import transformers.generation.utils because of the following error (look up to see its traceback):
module 'torch.nn' has no attribute 'RMSNorm'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\A_MyCodingWorkSpace\project\PyCharmProject\Qwen2-vl\Qwen2-VL-2B-Instruct\test.py", line 1, in <module>
    from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor
  File "<frozen importlib._bootstrap>", line 1229, in _handle_fromlist
  File "D:\A_MyCodingWorkSpace\environment\Anaconda3\Anaconda\envs\qwen2_vl\Lib\site-packages\transformers\utils\import_utils.py", line 1650, in __getattr__
    value = getattr(module, name)
            ^^^^^^^^^^^^^^^^^^^^^
  File "D:\A_MyCodingWorkSpace\environment\Anaconda3\Anaconda\envs\qwen2_vl\Lib\site-packages\transformers\utils\import_utils.py", line 1649, in __getattr__
    module = self._get_module(self._class_to_module[name])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\A_MyCodingWorkSpace\environment\Anaconda3\Anaconda\envs\qwen2_vl\Lib\site-packages\transformers\utils\import_utils.py", line 1661, in _get_module
    raise RuntimeError(
RuntimeError: Failed to import transformers.models.qwen2_vl.modeling_qwen2_vl because of the following error (look up to see its traceback):
Failed to import transformers.generation.utils because of the following error (look up to see its traceback):
module 'torch.nn' has no attribute 'RMSNorm'
@kq-chen
Copy link
Collaborator

kq-chen commented Sep 2, 2024

There have been similar issues before. You can take a look here: #12 and #52.

@kq-chen
Copy link
Collaborator

kq-chen commented Sep 2, 2024

the fix has been merged. you can re-install the latest transformers.

@kq-chen kq-chen closed this as completed Sep 2, 2024
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

2 participants