Pytorch 1.0 installation via conda cpu version undefined symbol

Hi,
I get undefined symbol as follows

conda create --name pytorch10
conda activate pytorch10
conda install pytorch-cpu torchvision-cpu -c pytorch
python

import torch

throws “anaconda3/envs/pytorch10/lib/python3.7/site-packages/torch/lib/libtorch.so.1: undefined symbol: _ZTIN2at10TensorImplE”

I have removed the conda environment and created another one and I keep getting the same error.

Did you build PyTorch from source in the past?
If so, try to uninstall it using pip uninstall torch; pip uninstall torch.

Hmmm.
I recreated the conda environment after removing it.

In fact, I went ahead reinstalled the whole anaconda. I still get the same error and seem to have this old version lingering somewhere.

I realize this is my corrupted setup problem. But any suggestion to track where the stale library could be coming from, would be appreciated.
Thanks for your suggestions

What does pip return if you try to uninstall torch?
Do you get a message that torch cannot be found?
If you just start a REPL using python in your terminal, are you able to import torch?
If so, could you run print(torch.__file__)?

I install via conda.
I did pip unistall twice like you had suggested.

First time itself, it succesfully uninstalls.

So far, I have been experimenting just like what you asked, doing “import torch” in python REPL. it has failing the same way.
The error is being thrown from libcaffe2_gpu.so

I want to run cpu version. Somehow the gpu version is popping up in the middle

Thanks for the information regarding Caffe2!
Have a look at this issue with some suggestions.
@ezyang suggests in this post:

If you want to use PyTorch master and Caffe2 together, please install them jointly with FULL_CAFFE2=1 python setup.py install , and make sure you don’t use any old pre-build binaries. I’m going to close this in favor of #10249 to track.

I dont have GPU. Looking only for CPU version. Why is the gpu.so throwing error? Any suggestions?

Can the joint installation of caffe2 and pytorch be done via conda?

Could I have one conda environment for pytorch and another for caffe2 (none of them need to have GPU support), could these be installed via conda?

How did you install caffe2 and PyTorch in the past?
It should be possible to install both using conda.
Currently some old lib seems to bug the import.

Also, as far as I know, caffe2 is already included in the current PyTorch binaries.
Could you just install the latest PyTorch release and try to import caffe2?
If that yields the same error, try to uninstall old caffe2 builds.

Last night, I built from source as indicated in https://github.com/pytorch/pytorch#from-source

export CMAKE_PREFIX_PATH="$(dirname $(which conda))/…/" # [anaconda root directory]

Install basic dependencies

conda install numpy pyyaml mkl mkl-include setuptools cmake cffi typing

git clone --recursive https://github.com/pytorch/pytorch
cd pytorch
python setup.py install (Had NO_CUDA=1 and FULL_CAFFE2=1) environmental variables.

Now,
Good News is when I go into the bin directory invoke the python from there and in the REPL if I import torch, it works. (This is python 2.7,btw)
print torch.version gives 1.0.0.a0+aec9fdf

But ‘from caffe2.python import core’ says ‘No Module named google.protobuf.internal’

Questions:

  1. How do I get python3 to work? The torch subdirectory gets installed under ./lib/python2.7/site-packages. (Under python3, import torch does not work.)
  2. I dont see FULL_CAFFE2 variable getting used in setup.py
  3. For protobuf problem for caffe2, what should I additionally install?
    Thanks for your help!

I found some old libcaffe2.so and libcaffe2_test_dynamic.so in my /usr/local/lib. Once I got rid of them, as suggested, I could import torch successfully.

Regarding caffe2, I had to additionally protobuf (conda install -c anaconda protobuf) and future (conda install -c anaconda future). Now, I can execute successfully (from caffe2.python import workspace).

Thanks for all the help.

1 Like

Good to hear you could fix this issue! :slight_smile:

Thanks for all the help.Good luck for you!:grinning: