OSError: /usr/local/lib/python3.7/dist-packages/torchtext/_torchtext.so: undefined symbol: _ZNK3c10

本文目录

说明:在Colab上跑模型报错,其中torch版本1.7。

运行截图:

OSError: /usr/local/lib/python3.7/dist-packages/torchtext/_torchtext.so: undefined symbol: _ZNK3c10

报错信息如下:

Traceback (most recent call last):
  File "tools/train_csc.py", line 11, in <module>
    from pytorch_lightning.callbacks import ModelCheckpoint
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/__init__.py", line 60, in <module>
    from pytorch_lightning import metrics
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/__init__.py", line 14, in <module>
    from pytorch_lightning.metrics.metric import Metric
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/metric.py", line 23, in <module>
    from pytorch_lightning.metrics.utils import _flatten, dim_zero_cat, dim_zero_mean, dim_zero_sum
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/utils.py", line 18, in <module>
    from pytorch_lightning.utilities import rank_zero_warn
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/__init__.py", line 24, in <module>
    from pytorch_lightning.utilities.apply_func import move_data_to_device
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/apply_func.py", line 25, in <module>
    from torchtext.data import Batch
  File "/usr/local/lib/python3.7/dist-packages/torchtext/__init__.py", line 40, in <module>
    _init_extension()
  File "/usr/local/lib/python3.7/dist-packages/torchtext/__init__.py", line 36, in _init_extension
    torch.ops.load_library(ext_specs.origin)
  File "/usr/local/lib/python3.7/dist-packages/torch/_ops.py", line 104, in load_library
    ctypes.CDLL(path)
  File "/usr/lib/python3.7/ctypes/__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /usr/local/lib/python3.7/dist-packages/torchtext/_torchtext.so: undefined symbol: _ZNK3c104Type14isSubtypeOfExtESt10shared_ptrIS0_EPSo

解决:

关键信息: OSError: /usr/local/lib/python3.7/dist-packages/torchtext/_torchtext.so: undefined symbol: _ZNK3c104Type14isSubtypeOfExtESt10shared_ptrIS0_EPSo

解释: torchtext的问题,优先考虑是不是版本不对应的问题。

1. 查找torch1.7对应torchtext版本

参考torchtext版本兼容官网repo:https://github.com/pytorch/text/

OSError: /usr/local/lib/python3.7/dist-packages/torchtext/_torchtext.so: undefined symbol: _ZNK3c10

; 2. 安装torchtext

pip install torchtext==0.8

OSError: /usr/local/lib/python3.7/dist-packages/torchtext/_torchtext.so: undefined symbol: _ZNK3c10

3. 重启kernel

参考资料:

pytorch 中 torchtext 遇到问题_torchtext.so undefined symbol解决方法(亲测有效)_阿正的梦工坊的博客-CSDN博客

Original: https://blog.csdn.net/qq_43800119/article/details/126468631
Author: zoetu
Title: OSError: /usr/local/lib/python3.7/dist-packages/torchtext/_torchtext.so: undefined symbol: _ZNK3c10

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/709472/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球