Cannot download ViTModel

For reproducility you can try the following commands:

from transformers import ViTModel
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'ViTModel' from 'transformers' (/opt/anaconda/anaconda3/envs/transformers/lib/python3.12/site-packages/transformers/__init__.py). Did you mean: 'GPT2Model'?

Any idea?

UPDATE:
uninstalling and reinstalling it (using PIP), I have now the 4.45.1 version installed.
Running the same command above gives me the following error:

Traceback (most recent call last):
  File "/opt/anaconda/anaconda3/envs/transformers/lib/python3.12/site-packages/transformers/utils/import_utils.py", line 1764, in _get_module
    return importlib.import_module("." + module_name, self.__name__)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda/anaconda3/envs/transformers/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/opt/anaconda/anaconda3/envs/transformers/lib/python3.12/site-packages/transformers/models/__init__.py", line 15, in <module>
    from . import (
  File "/opt/anaconda/anaconda3/envs/transformers/lib/python3.12/site-packages/transformers/models/mt5/__init__.py", line 29, in <module>
    from ..t5.tokenization_t5 import T5Tokenizer
  File "/opt/anaconda/anaconda3/envs/transformers/lib/python3.12/site-packages/transformers/models/t5/tokenization_t5.py", line 23, in <module>
    import sentencepiece as spm
  File "/opt/anaconda/anaconda3/envs/transformers/lib/python3.12/site-packages/sentencepiece/__init__.py", line 13, in <module>
    from . import _sentencepiece
ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /opt/anaconda/anaconda3/envs/transformers/lib/python3.12/site-packages/sentencepiece/_sentencepiece.cpython-312-x86_64-linux-gnu.so)

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

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 1412, in _handle_fromlist
  File "/opt/anaconda/anaconda3/envs/transformers/lib/python3.12/site-packages/transformers/utils/import_utils.py", line 1754, in __getattr__
    module = self._get_module(self._class_to_module[name])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda/anaconda3/envs/transformers/lib/python3.12/site-packages/transformers/utils/import_utils.py", line 1766, in _get_module
    raise RuntimeError(
RuntimeError: Failed to import transformers.models.auto because of the following error (look up to see its traceback):
/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /opt/anaconda/anaconda3/envs/transformers/lib/python3.12/site-packages/sentencepiece/_sentencepiece.cpython-312-x86_64-linux-gnu.so)
1 Like

pip install sentencepiece ?

1 Like

Almost…

pip install --upgrade sentencepiece

did the job

1 Like

If it works, OK.