zhanghang1989 / zhanghang1989/PyTorch-Encoding

ImportError when trying to import encoding or its modules

Open
#421 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2k
Forks
448
PR merge metrics
No merged PRs in 30d

Description

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!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce import encoding and from encoding.models.sseg import BaseNet with the reported Python, torch, and torch-encoding versions. Start at encoding/functions/encoding.py and the encoding/cpu extension named in the traceback, then compare the installed versions and CPU-only environment. Done means identifying the compatibility or installation cause and documenting a verified resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.