Pytorch3d: import error

Created on 8 Feb 2020  路  12Comments  路  Source: facebookresearch/pytorch3d

Hi, all,

I got the following import error:

>>> from pytorch3d import _C
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: /data/code11/pytorch3d/pytorch3d/_C.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZTIN3c1021AutogradMetaInterfaceE

My config is pytorch==1.4, torchvision==0.5.0, CUDA=10.0. It seems there's conflicts with the packages? Any hints to solve it?

THX!

bug

Most helpful comment

I think you may need import torch before a line like from pytorch3d import _C, which touches pytorch3d's internals, can possibly work.

All 12 comments

Does it work if you import pytorch3d before importing _C?

import pytorch3d
from pytorch3d import _C

Are you using the conda package or trying to install from source?

Thanks @jcjohnson @nikhilaravi for your replies.

@jcjohnson ,
import pytorch3d
This line works. But the second line from pytorch3d import _C prompts the above error.

@nikhilaravi ,
I install it from local clone as guided

@amiltonwong were you able to resolve this issue after installing from a local clone?

I think you may need import torch before a line like from pytorch3d import _C, which touches pytorch3d's internals, can possibly work.

@nikhilaravi @bottler , Thanks a lot for your help. It's solved after installing the new updated repo. I confirmed that import torch is needed before from pytorch3d import _C as mentioned by @bottler .

hi @bottler @amiltonwong @jcjohnson @nikhilaravi @likethesky
I installed pytorch3D according to https://github.com/facebookresearch/pytorch3d/blob/master/INSTALL.md
And I still get an error:

File "/userhome/pytorch3d/pytorch3d/renderer/blending.py", line 8, in <module>
from pytorch3d import _C
ImportError: cannot import name '_C'

My system setting:

  • python 3.6
  • pytorch 1.16
  • cuda 10.2
  • Ubuntu 16

I have confirmed that

import pytorch

has been added in front of the

from  pytorch3d import _C

image

Thank you in advance!

@Frank-Dz Please open a new issue and paste the output of conda list.

@Frank-Dz I have the same error.Have you solved it?

@bottler
My error is the same as Frank-Dz's which are as follows:

  • File "/userhome/pytorch3d/pytorch3d/renderer/blending.py", line 8, in
  • from pytorch3d import _C
  • ImportError: cannot import name '_C'

My pip list is:

  • addict 2.4.0
  • aiocontextvars 0.2.2
  • alfred-py 2.8.3
  • argon2-cffi 20.1.0
  • async-generator 1.10
  • attrs 20.3.0
  • backcall 0.2.0
  • bleach 3.2.1
  • certifi 2020.12.5
  • cffi 1.14.4
  • chardet 3.0.4
  • colorama 0.4.4
  • contextvars 2.4
  • cycler 0.10.0
  • dataclasses 0.8
  • decorator 4.4.2
  • defusedxml 0.6.0
  • Deprecated 1.2.10
  • entrypoints 0.3
  • funcy 1.15
  • future 0.18.2
  • fvcore 0.1.2.post20201210
  • idna 2.10
  • imageio 2.9.0
  • immutables 0.14
  • importlib-metadata 3.1.1
  • ipykernel 5.3.4
  • ipython 7.16.1
  • ipython-genutils 0.2.0
  • ipywidgets 7.5.1
  • jedi 0.17.2
  • Jinja2 2.11.2
  • joblib 0.17.0
  • jsonschema 3.2.0
  • jupyter-client 6.1.7
  • jupyter-core 4.7.0
  • jupyterlab-pygments 0.1.2
  • kiwisolver 1.3.1
  • loguru 0.5.3
  • lxml 4.6.2
  • MarkupSafe 1.1.1
  • matplotlib 3.3.3
  • mistune 0.8.4
  • nbclient 0.5.1
  • nbconvert 6.0.7
  • nbformat 5.0.8
  • nest-asyncio 1.4.3
  • networkx 2.5
  • notebook 6.1.5
  • numpy 1.19.4
  • open3d 0.8.0.0
  • opencv-python 4.4.0.46
  • packaging 20.7
  • pandas 1.1.5
  • pandocfilters 1.4.3
  • parso 0.7.1
  • pexpect 4.8.0
  • pickleshare 0.7.5
  • Pillow 8.0.1
  • pip 20.3.1
  • plotly 4.14.0
  • plyfile 0.7.2
  • portalocker 2.0.0
  • prometheus-client 0.9.0
  • prompt-toolkit 3.0.8
  • ptyprocess 0.6.0
  • pycparser 2.20
  • Pygments 2.7.3
  • pyparsing 2.4.7
  • pyquaternion 0.9.9
  • pyrsistent 0.17.3
  • python-dateutil 2.8.1
  • pytorch3d 0.3.0 /home/mxx/pytorch3d
  • pytz 2020.4
  • PyWavelets 1.1.1
  • PyYAML 5.3.1
  • pyzmq 20.0.0
  • regex 2020.11.13
  • requests 2.25.0
  • retrying 1.3.3
  • scikit-image 0.17.2
  • scikit-learn 0.23.2
  • scipy 1.5.4
  • Send2Trash 1.5.0
  • setuptools 51.0.0.post20201207
  • six 1.15.0
  • sklearn 0.0
  • tabulate 0.8.7
  • termcolor 1.1.0
  • terminado 0.9.1
  • testpath 0.4.4
  • threadpoolctl 2.1.0
  • tifffile 2020.9.3
  • torch 1.6.0+cu92
  • torchvision 0.7.0+cu92
  • tornado 6.1
  • tqdm 4.54.1
  • traitlets 4.3.3
  • typing-extensions 3.7.4.3
  • urllib3 1.26.2
  • wcwidth 0.2.5
  • webencodings 0.5.1
  • wheel 0.36.1
  • widgetsnbextension 3.5.1
  • wrapt 1.12.1
  • yacs 0.1.8
  • zipp 3.4.0

my sys setting is :

  • Ubuntu16
  • cuda9.2

@mengxiangxiang414 Please always open a new issue for things like this. How did you build/install PyTorch3D. It looks like you have installed from a local checkout of the repository, but did you actually build the library successfully? And did you build it with the current environment active? Were there and errors in building? Is there a file with a name beginning with _C in /home/mxx/pytorch3d/pytorch3d or /home/mxx/pytorch3d? Best to open a new issue with a post explaining all this if it is still problematic.

NOTE for future passers-by: If you have an import error with PyTorch3D which you cannot solve, please open a new issue.

@bottler
OK,thanks.
As you said锛孖 have installed from a local clone of the source, but did not actually build the library successfully.
Two bad actions resulted in my error :


  1. I ignored the

CUB library


  1. i retryed installing it without the

rm -rf build/ */.so

It was my mistake.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

elcronos picture elcronos  路  3Comments

eliemichel picture eliemichel  路  3Comments

OOF-dura picture OOF-dura  路  3Comments

abhi1kumar picture abhi1kumar  路  3Comments

ruslanvasylev picture ruslanvasylev  路  3Comments