Skip to content

ImportError when trying to import encoding or its modules #421

@zixinglin07

Description

@zixinglin07

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions