Skip to content

ImportError: cannot import name '_C' from 'pytorch3d' (Installation Error) #1013

@ParthGoyal1508

Description

@ParthGoyal1508

Installation issue from a local clone. I installed as mentioned here.

The build was successful but got errors in execution.

>>> import torch
>>> import pytorch3d
>>> from pytorch3d import _C
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name '_C' from 'pytorch3d' (/home/srijan.singh/pytorch3d/pytorch3d/__init__.py)

Instructions To Reproduce the Issue:

  1. Any changes you made (git diff) or code you wrote
No change 
  1. The exact command(s) you ran:
conda create -n Test 
conda activate Test
conda install -c pytorch pytorch=1.9.1 torchvision cudatoolkit=10.2
conda install -c fvcore -c iopath -c conda-forge fvcore iopath
conda install -c bottler nvidiacub

git clone https://github.com/facebookresearch/pytorch3d.git
cd pytorch3d 
python3 setup.py install 
  1. What you observed (including the full logs):
Traceback (most recent call last):
  File "/home/srijan.singh/pytorch3d/test.py", line 1, in <module>
    from pytorch3d.loss import chamfer_distance
  File "/home/srijan.singh/pytorch3d/pytorch3d/loss/__init__.py", line 8, in <module>
    from .chamfer import chamfer_distance
  File "/home/srijan.singh/pytorch3d/pytorch3d/loss/chamfer.py", line 11, in <module>
    from pytorch3d.ops.knn import knn_gather, knn_points
  File "/home/srijan.singh/pytorch3d/pytorch3d/ops/__init__.py", line 7, in <module>
    from .ball_query import ball_query
  File "/home/srijan.singh/pytorch3d/pytorch3d/ops/ball_query.py", line 10, in <module>
    from pytorch3d import _C
ImportError: cannot import name '_C' from 'pytorch3d' (/home/srijan.singh/pytorch3d/pytorch3d/__init__.py)
  1. Output of conda list
# packages in environment at /home/srijan.singh/miniconda3/envs/Test:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
_openmp_mutex             4.5                       1_gnu  
blas                      1.0                         mkl  
ca-certificates           2021.10.26           h06a4308_2  
certifi                   2021.10.8        py39h06a4308_0  
colorama                  0.4.4              pyh9f0ad1d_0    conda-forge
cudatoolkit               10.2.89              hfd86e86_1  
freetype                  2.11.0               h70c0345_0  
fvcore                    0.1.5.post20210804    pyhd8ed1ab_0    conda-forge
giflib                    5.2.1                h7b6447c_0  
intel-openmp              2021.4.0          h06a4308_3561  
iopath                    0.1.9                      py39    iopath
jpeg                      9d                   h7f8727e_0  
lcms2                     2.12                 h3be6417_0  
ld_impl_linux-64          2.35.1               h7274673_9  
libffi                    3.3                  he6710b0_2  
libgcc-ng                 9.3.0               h5101ec6_17  
libgomp                   9.3.0               h5101ec6_17  
libpng                    1.6.37               hbc83047_0  
libstdcxx-ng              9.3.0               hd4cf53a_17  
libtiff                   4.2.0                h85742a9_0  
libuv                     1.40.0               h7b6447c_0  
libwebp                   1.2.0                h89dd481_0  
libwebp-base              1.2.0                h27cfd23_0  
lz4-c                     1.9.3                h295c915_1  
mkl                       2021.4.0           h06a4308_640  
mkl-service               2.4.0            py39h7f8727e_0  
mkl_fft                   1.3.1            py39hd3c417c_0  
mkl_random                1.2.2            py39h51133e4_0  
ncurses                   6.3                  h7f8727e_2  
ninja                     1.10.2           py39hd09550d_3  
numpy                     1.21.2           py39h20f2e39_0  
numpy-base                1.21.2           py39h79a1101_0  
nvidiacub                 1.10.0                        0    bottler
olefile                   0.46               pyhd3eb1b0_0  
openssl                   1.1.1l               h7f8727e_0  
pillow                    8.4.0            py39h5aabda8_0  
pip                       21.2.4           py39h06a4308_0  
portalocker               2.3.2            py39hf3d152e_1    conda-forge
python                    3.9.7                h12debd9_1  
python_abi                3.9                      2_cp39    conda-forge
pytorch                   1.9.1           py3.9_cuda10.2_cudnn7.6.5_0    pytorch
pytorch3d                 0.6.1                    pypi_0    pypi
pyyaml                    5.4.1            py39h3811e60_0    conda-forge
readline                  8.1                  h27cfd23_0  
setuptools                58.0.4           py39h06a4308_0  
six                       1.16.0             pyhd3eb1b0_0  
sqlite                    3.37.0               hc218d9a_0  
tabulate                  0.8.9              pyhd8ed1ab_0    conda-forge
termcolor                 1.1.0                      py_2    conda-forge
tk                        8.6.11               h1ccaba5_0  
torchvision               0.2.2                      py_3    pytorch
tqdm                      4.62.3             pyhd8ed1ab_0    conda-forge
typing_extensions         3.10.0.2           pyh06a4308_0  
tzdata                    2021e                hda174b7_0  
wheel                     0.37.0             pyhd3eb1b0_1  
xz                        5.2.5                h7b6447c_0  
yacs                      0.1.8                    pypi_0    pypi
yaml                      0.2.5                h516909a_0    conda-forge
zlib                      1.2.11               h7f8727e_4  
zstd                      1.4.9                haebb681_0  

Could you please help me to resolve this? Thanks in advance.

Metadata

Metadata

Assignees

Labels

installationInstallation questions or issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions