Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError when trying to import encoding or its modules #421

Open
zixinglin07 opened this issue Mar 1, 2023 · 1 comment
Open

ImportError when trying to import encoding or its modules #421

zixinglin07 opened this issue Mar 1, 2023 · 1 comment

Comments

@zixinglin07
Copy link

Hi, I am trying to use encoding in my python project, however whenever I want to import encoding, or it's relevant modules I am met with an ImportError, just in the following example:

Python 3.7.13 (default, Mar 29 2022, 02:18:16) 
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import encoding
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/zixing/anaconda3/envs/lseg1/lib/python3.7/site-packages/encoding/__init__.py", line 13, in <module>
    from . import nn, functions, parallel, utils, models, datasets, transforms
  File "/home/zixing/anaconda3/envs/lseg1/lib/python3.7/site-packages/encoding/nn/__init__.py", line 12, in <module>
    from .encoding import *
  File "/home/zixing/anaconda3/envs/lseg1/lib/python3.7/site-packages/encoding/nn/encoding.py", line 18, in <module>
    from ..functions import scaled_l2, aggregate, pairwise_cosine
  File "/home/zixing/anaconda3/envs/lseg1/lib/python3.7/site-packages/encoding/functions/__init__.py", line 2, in <module>
    from .encoding import *
  File "/home/zixing/anaconda3/envs/lseg1/lib/python3.7/site-packages/encoding/functions/encoding.py", line 15, in <module>
    from encoding import cpu
ImportError: /home/zixing/anaconda3/envs/lseg1/lib/python3.7/site-packages/encoding/cpu.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN6caffe28TypeMeta21_typeMetaDataInstanceIN3c107complexIfEEEEPKNS_6detail12TypeMetaDataEv

The same error is present when I run the following import:

from encoding.models.sseg import BaseNet

I am running Ubuntu 22.04.2 on VM and I have installed Pytorch-Encoding using the suggested command "pip install git+https://github.com/zhanghang1989/PyTorch-Encoding/"

A couple of potential issues come to mind:

  1. I am running Ubuntu on VM, which makes it unable to use GPU or CUDA related features. I intend to only use CPU for my project. Could the issue be due to not having a GPU or CUDA installed? If so, is it possible to use Pytorch-Encoding with only CPU?
  2. Could Pytorch-Encoding not have been properly installed? I do not see a cpu module within my encoding folder inside my site-packages
  3. Could there be a mismatch in Pytorch versions? My current installed torch libraries are as follows:
torch                    1.9.1
torch-encoding           1.2.2b20230228
torchaudio               0.9.1
torchmetrics             0.5.1
torchvision              0.10.1

I look forward to any form of assistance or clarification so as to help me better understand my situation and try to resolve it. Thank you!

@zixinglin07
Copy link
Author

Update:

By moving the cpu.py file from another torch-encoding folder within the site-packages into the "encoding" folder, the error is gone and normal import of encoding works with no errors.

However when trying to include the encoding library into my project, the same line causes a different ImportError error:

  File "/home/zixing/anaconda3/envs/lseg1/lib/python3.7/site-packages/encoding/functions/encoding.py", line 15, in <module>
    from encoding import cpu
ImportError: /home/zixing/anaconda3/envs/lseg1/lib/python3.7/site-packages/encoding/cpu.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZNSt15__exception_ptr13exception_ptr9_M_addrefEv

I also tried using Python 3.6, but the same error occurs, with cpu.cpython-36m-x86_64-linux-gnu.so instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant