Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot import name 'nonzero_tuple' from 'detectron2.layers' #34

Closed
salmanhiro opened this issue Apr 13, 2021 · 1 comment
Closed

cannot import name 'nonzero_tuple' from 'detectron2.layers' #34

salmanhiro opened this issue Apr 13, 2021 · 1 comment

Comments

@salmanhiro
Copy link

salmanhiro commented Apr 13, 2021

cannot import name 'nonzero_tuple' from 'detectron2.layers'

I ran the code using Google Colab

  1. Full runnable code or full changes you made:
!pip install cython pyyaml==5.1
!pip install -U 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
import torch, torchvision
print(torch.__version__, torch.cuda.is_available())
!gcc --version


# install detectron2:
!pip install detectron2==0.1.3 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/torch1.5/index.html

# cloning centernet2 repository
!git clone https://github.com/xingyizhou/CenterNet2.git

# install detectron2:
!pip install detectron2==0.1.3 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/torch1.5/index.html
  1. What exact command you run:
#run training
%cd /content/CenterNet2/projects/CenterNet2
!python train_net.py --config-file configs/CenterNet-FPN_R50_1x.yaml --num-gpus 1
  1. Full logs or other relevant observations:
/content/CenterNet2/projects/CenterNet2
Traceback (most recent call last):
  File "train_net.py", line 38, in <module>
    from centernet.config import add_centernet_config
  File "/content/CenterNet2/projects/CenterNet2/centernet/__init__.py", line 3, in <module>
    from .modeling.roi_heads.custom_roi_heads import CustomROIHeads, CustomCascadeROIHeads
  File "/content/CenterNet2/projects/CenterNet2/centernet/modeling/roi_heads/custom_roi_heads.py", line 19, in <module>
    from .custom_fast_rcnn import CustomFastRCNNOutputLayers
  File "/content/CenterNet2/projects/CenterNet2/centernet/modeling/roi_heads/custom_fast_rcnn.py", line 13, in <module>
    from detectron2.layers import Linear, ShapeSpec, batched_nms, cat, nonzero_tuple
ImportError: cannot import name 'nonzero_tuple' from 'detectron2.layers' (/usr/local/lib/python3.7/dist-packages/detectron2/layers/__init__.py)

Expected behavior:

The initialization from centernet config runs, but since no dataset supported, it will not start the training process.

Environment:

Google colab

@salmanhiro
Copy link
Author

solved, it is related to cuda and pytorch version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant