I was working with PyTorch 1.5.0 for quite some time and decided to update to 1.9.0.
System: Ubuntu 18.04
Kernel: 4.15.0-147-generic #151-Ubuntu SMP
I use pyenv 2.0.3 to manage virtual environment and python versions.
I use python 3.7.9 installed with pyenv.
Make a new virtual environment with pyenv called XXXX.
My pip env shows
$ pip --version
pip 20.1.1 from /home/clement/.pyenv/versions/3.7.9/envs/XXXX/lib/python3.7/site-packages/pip (python 3.7)
$ pip uninstall torch torchvision torchaudio
WARNING: Skipping torch as it is not installed.
WARNING: Skipping torchvision as it is not installed.
WARNING: Skipping torchaudio as it is not installed.
$ python3 -c "import torch; torch.__version__"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'torch'

Everything is clean with the new setup.
Now install PyTorch 1.9.0 everything goes well no error message from pip
pip3 install torch==1.9.0+cpu torchvision==0.10.0+cpu torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

So everything looks fine but
$ python3 -c "import torch; torch.__version__"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/clement/.pyenv/versions/3.7.9/envs/XXXX/lib/python3.7/site-packages/torch/__init__.py", line 197, in <module>
    from torch._C import *  # noqa: F403
ImportError: /home/clement/.pyenv/versions/3.7.9/envs/XXXX/lib/python3.7/site-packages/torch/lib/libtorch_cpu.so: undefined symbol: _ZN3c1019UndefinedTensorImpl10_singletonE

I found that any version above 1.7.0 (included) give me this kind of error message.

1.7.0+cpu: _ZTIN3c1010TensorImplE
1.7.1+cpu: _ZTIN3c1010TensorImplE
1.8.0+cpu: _ZTIN3c1010TensorImplE
1.9.0+cpu: _ZN3c1019UndefinedTensorImpl10_singletonE

I also tried the “normal” version pip install torch==1.7.0 torchvision==0.8.0 torchaudio==0.7.0

1.7.0: _ZN3c107Warning4warnENS_14SourceLocationERKSsb
I don’t have any compatible GPU so maybe the above error is as expected?

I also tried with the python 3.6.9 from the ubuntu 18.04 repository I have the same behavior as above.
Furthermore, I tried to clean anything on my system that contains find / -iname *torch*.
Honestly I don’t know where to look for this issue. Any version prior to 1.7.0 install and works without any issues.
I use docker with Ubuntu 18.04, and I could install 1.7.1 and works with torch. I think this come from my workstation, but I have no clues. If someone knows where I can start to look at.