Maskrcnn-benchmark: Facing Import Error from torchvision import _C

Created on 14 Aug 2019  ·  10Comments  ·  Source: facebookresearch/maskrcnn-benchmark

🐛 Bug

Traceback (most recent call last):
File "tools/train_net.py", line 15, in
from maskrcnn_benchmark.data import make_data_loader
File "/home/harsh/maskrcnn-benchmark/maskrcnn_benchmark/data/__init__.py", line 2, in
from .build import make_data_loader
File "/home/harsh/maskrcnn-benchmark/maskrcnn_benchmark/data/build.py", line 11, in
from . import datasets as D
File "/home/harsh/maskrcnn-benchmark/maskrcnn_benchmark/data/datasets/__init__.py", line 2, in
from .coco import COCODataset
File "/home/harsh/maskrcnn-benchmark/maskrcnn_benchmark/data/datasets/coco.py", line 3, in
import torchvision
File "/home/harsh/anaconda3/envs/maskrcnn_benchmark/lib/python3.7/site-packages/torchvision/__init__.py", line 1, in
from torchvision import models
File "/home/harsh/anaconda3/envs/maskrcnn_benchmark/lib/python3.7/site-packages/torchvision/models/__init__.py", line 11, in
from . import detection
File "/home/harsh/anaconda3/envs/maskrcnn_benchmark/lib/python3.7/site-packages/torchvision/models/detection/__init__.py", line 1, in
from .faster_rcnn import *
File "/home/harsh/anaconda3/envs/maskrcnn_benchmark/lib/python3.7/site-packages/torchvision/models/detection/faster_rcnn.py", line 7, in
from torchvision.ops import misc as misc_nn_ops
File "/home/harsh/anaconda3/envs/maskrcnn_benchmark/lib/python3.7/site-packages/torchvision/ops/__init__.py", line 1, in
from .boxes import nms, box_iou
File "/home/harsh/anaconda3/envs/maskrcnn_benchmark/lib/python3.7/site-packages/torchvision/ops/boxes.py", line 2, in
from torchvision import _C
ImportError: /home/harsh/anaconda3/envs/maskrcnn_benchmark/lib/python3.7/site-packages/torchvision/_C.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN3c1019ComplexCUDATensorIdEv

Environment:
Collecting environment information...
PyTorch version: 1.0.0.dev20190328
Is debug build: No
CUDA used to build PyTorch: 9.0.176

OS: Ubuntu 16.04.6 LTS
GCC version: (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609
CMake version: version 3.5.1

Python version: 3.7
Is CUDA available: Yes
CUDA runtime version: 9.0.176
GPU models and configuration: GPU 0: TITAN Xp
Nvidia driver version: 396.54
cuDNN version: Could not collect

Versions of relevant libraries:
[pip] numpy==1.17.0
[pip] torch==1.1.0
[pip] torchvision==0.3.0
[conda] blas 1.0 mkl
[conda] mkl 2019.4 243
[conda] mkl_fft 1.0.12 py37ha843d7b_0
[conda] mkl_random 1.0.2 py37hd81dba3_0
[conda] pytorch 1.1.0 py3.7_cuda9.0.176_cudnn7.5.1_0 pytorch
[conda] pytorch-nightly 1.0.0.dev20190328 py3.7_cuda9.0.176_cudnn7.4.2_0 pytorch
[conda] torchvision 0.3.0 py37_cu9.0.176_1 pytorch

Most helpful comment

for me,
pip install torchvision==0.2.2
OK

All 10 comments

I have the same bug with you.Did you slove it?

I left this model and moved this matterport/mask-rcnn.

was having lots of issues in this.

One of most common root causes of this type of error comes from different versions of PyTorch used to compile extensions. What I see in your environment report is that your torchvision is built for torch 1.1, whereas your runtime uses torch 1.0.0.dev....

Maybe cloning and compiling torchvision from source in your runtime environment will fix this bug.

for me,
pip install torchvision==0.2.2
OK

for me,
pip install torchvision==0.2.2
OK

thank you! your method solved my problem

for me,
pip install torchvision==0.2.2
OK

It works for me, as well! Thanks

对我来说,
pip install torchvision == 0.2.2

I met the same problem, but according to what you said, I still did not deal with the error.

对我来说,
pip install torchvision == 0.2.2

我遇到了同样的问题,但是根据您所说的,我仍然没有处理该错误。
Traceback (most recent call last):
File "tools/train_net.py", line 15, in
from maskrcnn_benchmark.data import make_data_loader
File "/home/xinneng/maskrcnn-benchmark-master/maskrcnn-benchmark/maskrcnn_benchmark/data/__init__.py", line 2, in
from .build import make_data_loader
File "/home/xinneng/maskrcnn-benchmark-master/maskrcnn-benchmark/maskrcnn_benchmark/data/build.py", line 11, in
from . import datasets as D
File "/home/xinneng/maskrcnn-benchmark-master/maskrcnn-benchmark/maskrcnn_benchmark/data/datasets/__init__.py", line 3, in
from .coco import COCODataset
File "/home/xinneng/maskrcnn-benchmark-master/maskrcnn-benchmark/maskrcnn_benchmark/data/datasets/coco.py", line 6, in
from maskrcnn_benchmark.structures.segmentation_mask import SegmentationMask
File "/home/xinneng/maskrcnn-benchmark-master/maskrcnn-benchmark/maskrcnn_benchmark/structures/segmentation_mask.py", line 5, in
from maskrcnn_benchmark.layers.misc import interpolate
File "/home/xinneng/maskrcnn-benchmark-master/maskrcnn-benchmark/maskrcnn_benchmark/layers/__init__.py", line 10, in
from .nms import nms
File "/home/xinneng/maskrcnn-benchmark-master/maskrcnn-benchmark/maskrcnn_benchmark/layers/nms.py", line 3, in
from maskrcnn_benchmark import _C
ImportError: /home/xinneng/maskrcnn-benchmark-master/maskrcnn-benchmark/maskrcnn_benchmark/_C.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZN3c1019ComplexCUDATensorIdEv
Solutions

is there any way where needn't downgrade torchvision0.3 to torchvision0.2 ?

conda create -n maskrcnn_env

conda activate maskrcnn_env

conda install pip

pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple

pip install scikit-build -i https://pypi.tuna.tsinghua.edu.cn/simple

pip install ninja yacs cython matplotlib tqdm opencv-python ipython requests -i https://mirrors.aliyun.com/pypi/simple

conda install --use-local /home/deploy/anaconda3/pkgs/blas-1.0-mkl.tar.bz2
conda install --use-local /home/deploy/anaconda3/pkgs/cffi-1.10.0-py36_0.tar.bz2
conda install --use-local /home/deploy/anaconda3/pkgs/cudatoolkit-10.0.130-0.tar.bz2
conda install --use-local /home/deploy/anaconda3/pkgs/freetype-2.5.5-2.tar.bz2
conda install --use-local /home/deploy/anaconda3/pkgs/intel-openmp-2019.4-243.tar.bz2
conda install --use-local /home/deploy/anaconda3/pkgs/jbig-2.1-0.tar.bz2
conda install --use-local /home/deploy/anaconda3/pkgs/jpeg-9b-0.tar.bz2
conda install --use-local /home/deploy/anaconda3/pkgs/libffi-3.2.1-1.tar.bz2
conda install --use-local /home/deploy/anaconda3/pkgs/libpng-1.6.30-1.tar.bz2
conda install --use-local /home/deploy/anaconda3/pkgs/libtiff-4.0.6-3.tar.bz2
conda install --use-local /home/deploy/anaconda3/pkgs/mkl-2018.0.3-1.tar.bz2
conda install --use-local /home/deploy/anaconda3/pkgs/ninja-1.7.2-0.tar.bz2
conda install --use-local /home/deploy/anaconda3/pkgs/olefile-0.44-py36_0.tar.bz2
conda install --use-local /home/deploy/anaconda3/pkgs/pillow-4.2.1-py36_0.tar.bz2
conda install --use-local /home/deploy/anaconda3/pkgs/pycparser-2.18-py36_0.tar.bz2
conda install --use-local /home/deploy/anaconda3/pkgs/pytorch-1.4.0-py3.6_cuda10.0.130_cudnn7.6.3_0.tar.bz2
conda install --use-local /home/deploy/anaconda3/pkgs/pytorch-nightly-1.0.0.dev20190328-py3.6_cuda10.0.130_cudnn7.4.2_0.tar.bz2
conda install --use-local /home/deploy/anaconda3/pkgs/six-1.10.0-py36_0.tar.bz2
conda install --use-local /home/deploy/anaconda3/pkgs/torchvision-0.4.0-py36_cu100.tar.bz2

Was this page helpful?
0 / 5 - 0 ratings