RuntimeError: Failed to import transformers.models.roberta.modeling_roberta because of the following error
#4
by
donhuvy
- opened
I am using Windows 11 x64, CUDA 12.8, PyTorch nightly.
Microsoft Windows [Version 10.0.26100.3476]
(c) Microsoft Corporation. All rights reserved.
C:\Users\ADMIN>nvidia-smi
Sun Mar 30 23:06:51 2025
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 572.83 Driver Version: 572.83 CUDA Version: 12.8 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Driver-Model | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA GeForce RTX 5090 WDDM | 00000000:01:00.0 On | N/A |
| 0% 31C P8 24W / 575W | 1386MiB / 32607MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| 0 N/A N/A 2508 C+G ....0.3124.93\msedgewebview2.exe N/A |
| 0 N/A N/A 2936 C+G ...yb3d8bbwe\WindowsTerminal.exe N/A |
| 0 N/A N/A 3120 C+G ...em32\ApplicationFrameHost.exe N/A |
| 0 N/A N/A 6632 C+G ...xyewy\ShellExperienceHost.exe N/A |
| 0 N/A N/A 6824 C+G ...indows\System32\ShellHost.exe N/A |
| 0 N/A N/A 6964 C+G C:\Windows\explorer.exe N/A |
| 0 N/A N/A 6984 C+G ...IA app\CEF\NVIDIA Overlay.exe N/A |
| 0 N/A N/A 7448 C+G ...Files\Notepad++\notepad++.exe N/A |
| 0 N/A N/A 7772 C+G ...rm 2024.3.5\bin\pycharm64.exe N/A |
| 0 N/A N/A 7920 C+G ...ntrolPanel\SystemSettings.exe N/A |
| 0 N/A N/A 11964 C+G ...y\StartMenuExperienceHost.exe N/A |
| 0 N/A N/A 12064 C+G ..._cw5n1h2txyewy\SearchHost.exe N/A |
| 0 N/A N/A 12480 C+G ...IA app\CEF\NVIDIA Overlay.exe N/A |
| 0 N/A N/A 15228 C+G ....0.3124.93\msedgewebview2.exe N/A |
| 0 N/A N/A 17420 C+G ...8bbwe\PhoneExperienceHost.exe N/A |
| 0 N/A N/A 17612 C+G ...Chrome\Application\chrome.exe N/A |
| 0 N/A N/A 18328 C+G ...s\PowerToys.PowerLauncher.exe N/A |
| 0 N/A N/A 19648 C+G ...adeonsoftware\AMDRSSrcExt.exe N/A |
| 0 N/A N/A 20392 C+G ...crosoft OneDrive\OneDrive.exe N/A |
| 0 N/A N/A 21448 C+G ....0.3124.93\msedgewebview2.exe N/A |
| 0 N/A N/A 22356 C+G ...8wekyb3d8bbwe\WebViewHost.exe N/A |
+-----------------------------------------------------------------------------------------+
C:\Users\ADMIN>
I catch error , please help me https://gist.github.com/donhuvy/a8c6311fc07903bb72d3b62ec785463f
# https://huggingface.co/docs/transformers/main/en/model_doc/phobert
import sys
print(sys.executable)
print(sys.version)
print(sys.version_info)
C:\Users\ADMIN\PyCharmMiscProject\.venv\Scripts\python.exe
3.11.9 (tags/v3.11.9:de54cf5, Apr 2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)]
sys.version_info(major=3, minor=11, micro=9, releaselevel='final', serial=0)
import torch
print(torch.__version__)
print(torch.version.cuda)
2.8.0.dev20250322+cu128
12.8
#%%
import torch
from transformers import AutoModel, AutoTokenizer
phobert = AutoModel.from_pretrained("vinai/phobert-base-v2")
tokenizer = AutoTokenizer.from_pretrained("vinai/phobert-base-v2")
# INPUT TEXT MUST BE ALREADY WORD-SEGMENTED!
sentence = 'Chúng_tôi là những nghiên_cứu_viên .'
input_ids = torch.tensor([tokenizer.encode(sentence)])
with torch.no_grad():
features = phobert(input_ids) # Models outputs are now tuples
## With TensorFlow 2.0+:
# from transformers import TFAutoModel
# phobert = TFAutoModel.from_pretrained("vinai/phobert-base")
C:\Users\ADMIN\PyCharmMiscProject\.venv\Lib\site-packages\huggingface_hub\file_download.py:142: UserWarning: `huggingface_hub` cache-system uses symlinks by default to efficiently store duplicated files but your machine does not support them in C:\Users\ADMIN\.cache\huggingface\hub\models--vinai--phobert-base-v2. Caching files will still work but in a degraded version that might require more space on your disk. This warning can be disabled by setting the `HF_HUB_DISABLE_SYMLINKS_WARNING` environment variable. For more details, see https://huggingface.co/docs/huggingface_hub/how-to-cache#limitations.