Libtorch_cpu.so: undefined symbol

Minimal env

Even a minimal Environment like below would throw similar errors:

conda create -n minimal_pytorch python=3.6 pytorch torchvision torchaudio -c pytorch
source activate minimal_pytorch && python -c "import torch; print(torch.__version__)"

A similar undefined symbol error is thrown:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/envs/minimal_pytorch/lib/python3.6/site-packages/torch/__init__.py", line 197, in <module>
    from torch._C import *  # noqa: F403
ImportError: /usr/local/envs/minimal_pytorch/lib/python3.6/site-packages/torch/lib/libtorch_cpu.so: undefined symbol: iJIT_NotifyEvent

Python version

When Python version is omitted while creating the environment:

conda create -n minimal_pytorch python pytorch torchvision torchaudio -c pytorch

The error is resolved:

source activate minimal_pytorch && python -c "import torch; print(torch.__version__)"

PyTorch version is received without any error:

2.2.2

I’m kind of confused :roll_eyes:

Eventually, I guess I have to use a Docker container as suggested here:

The PyTorch binaries are not built for Python 3.6 anymore, so the first command should install a torch<=1.10.2 if I’m not mistaken.
Use a newer Python version (3.8 - 3.12) and it should work.

1 Like

I’m facing this issue with python 3.9.*, when installing pytorch via conda.

Eventually, I solved the problem by resolving version mismatches. The exact commands are here: