transformer 报错 AttributeError: module ‘torch.utils._pytree‘ has no attribute ‘register_pytree_node‘

问题解决

降低 transformer 版本:pip install transformers==4.36.0(先卸载现有版本pip uninstall transformers
44和40版本都报错

(yolov8) PS C:\Users\10556\Downloads> # 2. 验证安装结果 (yolov8) PS C:\Users\10556\Downloads> python -c "import torchvision; print(f'TorchVision版本: {torchvision.__version__}, CUDA状态: {torchvision._C._cuda_available}')" A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.2 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'. If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2. Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\mini\envs\yolov8\lib\site-packages\torchvision\__init__.py", line 5, in <module> import torch File "C:\mini\envs\yolov8\lib\site-packages\torch\__init__.py", line 1471, in <module> from .functional import * # noqa: F403 File "C:\mini\envs\yolov8\lib\site-packages\torch\functional.py", line 9, in <module> import torch.nn.functional as F File "C:\mini\envs\yolov8\lib\site-packages\torch\nn\__init__.py", line 1, in <module> from .modules import * # noqa: F403 File "C:\mini\envs\yolov8\lib\site-packages\torch\nn\modules\__init__.py", line 35, in <module> from .transformer import TransformerEncoder, TransformerDecoder, \ File "C:\mini\envs\yolov8\lib\site-packages\torch\nn\modules\transformer.py", line 20, in <module> device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'), C:\mini\envs\yolov8\lib\site-packages\torch\nn\modules\transformer.py:20: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at C:\actions-runner\_work\pytorch\pytorch\builder\windows\pytorch\torch\csrc\utils\tensor_numpy.cpp:84.) device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'), Traceback (most recent call last): File "<string>", line 1, in <module> AttributeError: module 'torchvision' has no attribute '_C' (yolov8) PS C:\Users\10556\Downloads> (yolov8) PS C:\Users\10556\Downloads> # 3. 检查PyTorch整体环境 (yolov8) PS C:\Users\10556\Downloads> python -c "import torch; print(f'PyTorch版本: {torch.__version__}, CUDA可用: {torch.cuda.is_available()}')" A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.2 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'. If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2. Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\mini\envs\yolov8\lib\site-packages\torch\__init__.py", line 1471, in <module> from .functional import * # noqa: F403 File "C:\mini\envs\yolov8\lib\site-packages\torch\functional.py", line 9, in <module> import torch.nn.functional as F File "C:\mini\envs\yolov8\lib\site-packages\torch\nn\__init__.py", line 1, in <module> from .modules import * # noqa: F403 File "C:\mini\envs\yolov8\lib\site-packages\torch\nn\modules\__init__.py", line 35, in <module> from .transformer import TransformerEncoder, TransformerDecoder, \ File "C:\mini\envs\yolov8\lib\site-packages\torch\nn\modules\transformer.py", line 20, in <module> device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'), C:\mini\envs\yolov8\lib\site-packages\torch\nn\modules\transformer.py:20: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at C:\actions-runner\_work\pytorch\pytorch\builder\windows\pytorch\torch\csrc\utils\tensor_numpy.cpp:84.) device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'), PyTorch版本: 2.2.0+cu118, CUDA可用: True
09-10
>>> import torch A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.1 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'. If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2. Traceback (most recent call last): File "<stdin>", line 1, in <module> File "E:\Anaconda_backup\envs\pytorch2.2.2\lib\site-packages\torch\__init__.py", line 1477, in <module> from .functional import * # noqa: F403 File "E:\Anaconda_backup\envs\pytorch2.2.2\lib\site-packages\torch\functional.py", line 9, in <module> import torch.nn.functional as F File "E:\Anaconda_backup\envs\pytorch2.2.2\lib\site-packages\torch\nn\__init__.py", line 1, in <module> from .modules import * # noqa: F403 File "E:\Anaconda_backup\envs\pytorch2.2.2\lib\site-packages\torch\nn\modules\__init__.py", line 35, in <module> from .transformer import TransformerEncoder, TransformerDecoder, \ File "E:\Anaconda_backup\envs\pytorch2.2.2\lib\site-packages\torch\nn\modules\transformer.py", line 20, in <module> device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'), E:\Anaconda_backup\envs\pytorch2.2.2\lib\site-packages\torch\nn\modules\transformer.py:20: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at C:\cb\pytorch_1000000000000\work\torch\csrc\utils\tensor_numpy.cpp:84.) device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'), >>> torch.cuda.is_avaiable() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: module 'torch.cuda' has no attribute 'is_avaiable'
07-19
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值