Ubuntu 18.04 Anconda3 Pytorch1.0 suddently not working

Hi, I was using Anaconda for pytorch. Everything works perfectly until a few days ago. It stops working.

I tried many different ways to solve this problem. However, the issue still exists.
I remove anaconda and reinstall a new anaconda, create a new environment and install a new pytorch.

Unfortunately, the errors are still there. I provide the following error messages. Any suggestions are appreciated.

Python 3.7.2 (default, Dec 29 2018, 06:19:36) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/qyou/anaconda3/envs/pytorch1.0/lib/python3.7/site-packages/torch/__init__.py", line 84, in <module>
    from torch._C import *
ImportError: /home/qyou/anaconda3/envs/pytorch1.0/lib/python3.7/site-packages/torch/lib/libtorch_python.so: undefined symbol: _ZTIN5torch8autograd9generated33MkldnnConvolutionBackwardBackwardE

Thanks

This error is usually thrown, when an old shared library somewhere on your system.
Did you build PyTorch from source recently?
If so, could you run this command:

pip uninstall torch; pip uninstall torch

(it should really run twice, that’s not a typo :wink: )

I did not build PyTorch from source recently. I also tried

pip uninstall torch; pip uninstall torch

and then reinstall PyTorch

conda install -c pytorch pytorch

The error is the same.

Could you run the following commands to check for other PyTorch installs (e.g. pytorch-nightly):

conda list | grep torch
pip list | grep torch

Thanks.

Here is the output:

$conda list | grep torch
# packages in environment at /home/qyou/anaconda3/envs/pytorch1.0:
pytorch                   1.0.1           py3.7_cuda10.0.130_cudnn7.4.2_2    pytorch
torchvision               0.2.1                      py_2    pytorch

pip list | grep torch
torch       1.0.1.post2
torchvision 0.2.1 

I also tried the pytorch-nightly, the error is similar in libtorch_python.so, but with different undefined symbol as follows:

Python 3.7.2 (default, Dec 29 2018, 06:19:36) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/qyou/anaconda3/envs/pytorch1.0/lib/python3.7/site-packages/torch/__init__.py", line 84, in <module>
    from torch._C import *
ImportError: /home/qyou/anaconda3/envs/pytorch1.0/lib/python3.7/site-packages/torch
/lib/libtorch_python.so: undefined symbol: _ZTIN3c1021AutogradMetaInterfaceE

These is somewhere the libaten still on your system.
Could you check your LD_LIBRARY_PATH for unnecessary paths?
Also just to make sure we get rid of all installs, could you run this again:

conda uninstall -y pytorch-nightly
conda uninstall -y pytorch
pip uninstall -y torch
pip uninstall -y torch
pip uninstall -y torch

conda install -y pytorch-nightly

Thanks. Problem solved.

I used libtorch C++ and add its path to the system environments to make the C++ program runnable.

After I remove the path, now pytorch works.

1 Like