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

本文目录

  • 运行截图:
  • 解决:
    • 1. 查找torch1.7对应torchtext版本
    • 2. 安装torchtext
    • 3. 重启kernel
  • 参考资料:

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


运行截图:

OSError: /usr/local/lib/python3.7/dist-packages/torchtext/_torchtext.so: undefined symbol: _ZNK3c10_第1张图片

报错信息如下:

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张图片

2. 安装torchtext

pip install torchtext==0.8

OSError: /usr/local/lib/python3.7/dist-packages/torchtext/_torchtext.so: undefined symbol: _ZNK3c10_第3张图片

3. 重启kernel

参考资料:

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

你可能感兴趣的:(Error,pytorch,深度学习,python)