# Undefined symbol pytorch 1.7.0 and above

**URL:** <https://discuss.pytorch.org/t/undefined-symbol-pytorch-1-7-0-and-above/126640>\
**Category:** Uncategorized\
**Created:** [July 13, 2021, 3:13pm UTC](https://discuss.pytorch.org/t/undefined-symbol-pytorch-1-7-0-and-above/126640 "2021-07-13T15:13:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![czotti](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/czotti/32/8031_2.png) [@czotti](https://discuss.pytorch.org/u/czotti)\
**Post date:** [July 13, 2021, 3:13pm UTC](https://discuss.pytorch.org/t/undefined-symbol-pytorch-1-7-0-and-above/126640/1 "2021-07-13T15:13:39Z")

</div>

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

```auto
$ 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

```auto
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

```auto
$ 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.

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [July 14, 2021, 8:53am UTC](https://discuss.pytorch.org/t/undefined-symbol-pytorch-1-7-0-and-above/126640/2 "2021-07-14T08:53:16Z")

</div>

Usually you would get this error message if you are trying to `import` custom extensions before importing PyTorch, which doesn’t seem to be the case here.  
I also assume that you don’t have any files, which could cause conflicts, in the current working directory.  
In that case, could you create a new virtual environment, install PyTorch there, and test it again?

---

<div class="post-metadata">

**Author:** ![czotti](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/czotti/32/8031_2.png) [@czotti](https://discuss.pytorch.org/u/czotti)\
**Post date:** [July 14, 2021, 5:30pm UTC](https://discuss.pytorch.org/t/undefined-symbol-pytorch-1-7-0-and-above/126640/3 "2021-07-14T17:30:33Z")

</div>

No directory/file was named torch on my working folder, if it was the case I assume that torch==1.6.0 will also fail no ?

Here are the steps I have done for the new venv:

```auto
$ mkdir new_venv
$ cd new_venv
$ virtualenv -p python3 pytorch_test
Running virtualenv with interpreter /home/clement/.pyenv/shims/python3
Using base prefix '/usr'
New python executable in /home/clement/new_env/pytorch_test/bin/python3
Also creating executable in /home/clement/new_env/pytorch_test/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
$ source pytorch_test/bin/activate
(pytorch_test) $ where python3
/home/clement/new_env/pytorch_test/bin/python3
/usr/bin/python3
(pytorch_test) $ pip freeze
pkg-resources==0.0.0
(pytorch_test) $ pip install torch==1.7.0+cpu torchvision==0.8.0 torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
(pytorch_test) $ python3 -c "import torch; print(torch. __version__ )"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/clement/new_env/pytorch_test/lib/python3.6/site-packages/torch/ __init__.py", line 190, in <module>
    from torch._C import *
ImportError: /home/clement/new_env/pytorch_test/lib/python3.6/site-packages/torch/lib/libtorch_cpu.so: undefined symbol: _ZTIN3c1010TensorImplE
(pytorch_test) $ pip uninstall torch torchvision torchaudio
(pytorch_test) $ 
(pytorch_test) $ pip install torch==1.6.0+cpu torchvision==0.7.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
(pytorch_test) $ python3 -c "import torch; print(torch. __version__ )"
1.6.0+cpu

```

---

<div class="post-metadata">

**Author:** ![czotti](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/czotti/32/8031_2.png) [@czotti](https://discuss.pytorch.org/u/czotti)\
**Post date:** [August 6, 2021, 6:54pm UTC](https://discuss.pytorch.org/t/undefined-symbol-pytorch-1-7-0-and-above/126640/4 "2021-08-06T18:54:30Z")

</div>

The only way I found to make it work is to use a docker container with the required PyTorch version in it.
