I have setup an Amazon Linux EC2 gpu instance with Python 3.11.6 and am trying to import torch and torch text:
>>> import torch
>>> from torchtext.vocab import build_vocab_from_iterator
This raises the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ec2-user/***/.env/lib64/python3.11/site-packages/torchtext/__init__.py", line 6, in <module>
from torchtext import _extension # noqa: F401
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ec2-user/***/.env/lib64/python3.11/site-packages/torchtext/_extension.py", line 64, in <module>
_init_extension()
File "/home/ec2-user/***/.env/lib64/python3.11/site-packages/torchtext/_extension.py", line 58, in _init_extension
_load_lib("libtorchtext")
File "/home/ec2-user/***/.env/lib64/python3.11/site-packages/torchtext/_extension.py", line 50, in _load_lib
torch.ops.load_library(path)
File "/home/ec2-user/***/.env/lib64/python3.11/site-packages/torch/_ops.py", line 1350, in load_library
ctypes.CDLL(path)
File "/usr/lib64/python3.11/ctypes/__init__.py", line 376, in __init__
self._handle = _dlopen(self._name, mode)
^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: /home/ec2-user/***/.env/lib/python3.11/site-packages/torchtext/lib/libtorchtext.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSs
I’ve seen other people have run into this issue when they have multiple versions of torch installed, but this instance doesn’t have anything else installed, so I’m at a loss. Any ideas?