aim-uofa / AdelaiDet

AdelaiDet is an open source toolbox for multiple instance-level detection and recognition tasks.
https://git.io/AdelaiDet
Other
3.38k stars 648 forks source link

ABCNet demo ERROR #114

Closed Eurus-Holmes closed 4 years ago

Eurus-Holmes commented 4 years ago

Hi, thanks for your great work! But when I run the ABCNet demo, it occurred an error. Just for a simple test, I use the my own dataset, following your demo command:

python demo/demo.py \
    --config-file configs/BAText/CTW1500/attn_R_50.yaml \
    --input ./input/ \
    --output ./output/ \
    --opts MODEL.WEIGHTS ctw1500_attn_R_50.pth

the error is:

Traceback (most recent call last):
  File "demo/demo.py", line 86, in <module>
    predictions, visualized_output = demo.run_on_image(img)
  File "./AdelaiDet/demo/predictor.py", line 53, in run_on_image
    predictions = self.predictor(image)
  File "./AdelaiDet/env/lib/python3.7/site-packages/detectron2/engine/defaults.py", line 218, in __call__
    predictions = self.model([inputs])[0]
  File "./AdelaiDet/env/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "./AdelaiDet/adet/modeling/one_stage_detector.py", line 100, in forward
    return self.inference(batched_inputs)
  File "./AdelaiDet/adet/modeling/one_stage_detector.py", line 164, in inference
    results, _ = self.roi_heads(images, features, proposals, None)
  File "./AdelaiDet/env/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "./AdelaiDet/adet/modeling/roi_heads/text_head.py", line 158, in forward
    bezier_features = self.pooler(features, beziers)
  File "./AdelaiDet/env/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "./AdelaiDet/adet/modeling/poolers.py", line 161, in forward
    output[inds] = pooler(x_level, pooler_fmt_boxes_level)
  File "./AdelaiDet/env/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "./AdelaiDet/adet/layers/bezier_align.py", line 87, in forward
    input, rois, self.output_size, self.spatial_scale, self.sampling_ratio, self.aligned
  File "./AdelaiDet/adet/layers/bezier_align.py", line 20, in forward
    input, roi, spatial_scale, output_size[0], output_size[1], sampling_ratio, aligned
RuntimeError: Not compiled with GPU support

I don't understand why GPU support is not compiled, because when I run the FCOS demo with my same dataset, it will work.

python demo/demo.py \
    --config-file configs/FCOS-Detection/R_50_1x.yaml \
    --input ./input/ \
    --output ./output/ \
    --opts MODEL.WEIGHTS fcos_R_50_1x.pth
innat commented 4 years ago

Are you trying with CPU? I think, in order to run ABCNet, you need GPU to compile and run.

Eurus-Holmes commented 4 years ago

Are you trying with CPU? I think, in order to run ABCNet, you need GPU to compile and run.

No, I'm trying with GPU.

>>> import torch
>>> print("torch.cuda.is_available() =", torch.cuda.is_available())
torch.cuda.is_available() = True
>>> print("torch.backends.cudnn.is_available() =", torch.backends.cudnn.is_available())
torch.backends.cudnn.is_available() = True
>>> print("torch.rand(2, 3).cuda() =", torch.rand(2, 3).cuda())
torch.rand(2, 3).cuda() = tensor([[0.7986, 0.8999, 0.7932],
        [0.8926, 0.6369, 0.9564]], device='cuda:0')
Yuliang-Liu commented 4 years ago

@Eurus-Holmes This is weird. We did not encounter this issue before.

I guess it might be because of your conda environment. Try reinstall the anaconda and then follow the instruction to install again? Can you try install on another computer and see if the problem still exists?

If the question still unsolved, would you please show me your conda list and the detail of your graphics card?

Eurus-Holmes commented 4 years ago

@Yuliang-Liu I used venv environment instead of conda, is that a problem?

Following the instruction, I install by these commands:

git clone https://github.com/aim-uofa/AdelaiDet.git
cd AdelaiDet
python -m venv env
source env/bin/activate
pip install --upgrade pip
pip install -U torch==1.5 torchvision==0.6 -f https://download.pytorch.org/whl/cu101/torch_stable.html 
pip install cython pyyaml==5.1
pip install -U 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
pip install detectron2==0.1.3 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/torch1.5/index.html
python setup.py build develop

And this is my pip list:

Package                Version            Location
---------------------- ------------------ -----------------------
absl-py                0.9.0
AdelaiDet              0.2.0              ./AdelaiDet
cachetools             4.1.0
certifi                2020.6.20
chardet                3.0.4
cloudpickle            1.4.1
cycler                 0.10.0
Cython                 0.29.20
detectron2             0.1.3+cu101
future                 0.18.2
fvcore                 0.1.1.post20200622
google-auth            1.18.0
google-auth-oauthlib   0.4.1
grpcio                 1.29.0
idna                   2.9
importlib-metadata     1.6.1
kiwisolver             1.2.0
Markdown               3.2.2
matplotlib             3.2.2
mock                   4.0.2
numpy                  1.19.0
oauthlib               3.1.0
opencv-python          4.2.0.34
Pillow                 7.1.2
pip                    20.1.1
Polygon3               3.0.8
portalocker            1.7.0
protobuf               3.12.2
pyasn1                 0.4.8
pyasn1-modules         0.2.8
pycocotools            2.0
pydot                  1.4.1
pyparsing              2.4.7
python-dateutil        2.8.1
python-Levenshtein     0.12.0
PyYAML                 5.1
requests               2.24.0
requests-oauthlib      1.3.0
rsa                    4.6
setuptools             47.3.1
Shapely                1.7.0
six                    1.15.0
tabulate               0.8.7
tensorboard            2.2.2
tensorboard-plugin-wit 1.6.0.post3
termcolor              1.1.0
torch                  1.5.0+cu101
torchvision            0.6.0+cu101
tqdm                   4.46.1
urllib3                1.25.9
Werkzeug               1.0.1
wheel                  0.34.2
yacs                   0.1.7
zipp                   3.1.0

About CUDA Version:

NVIDIA-SMI 418.116.00   Driver Version: 418.116.00   CUDA Version: 10.1
innat commented 4 years ago

@Eurus-Holmes I've made an inference kernel using ABCNet on Total-Text data set in Kaggle. This may not solve your local problem, however. If you prefer to run the kernel with this data set, here are the links:

Eurus-Holmes commented 4 years ago

@innat Thanks for your share! It's really weird, I found your code and installation process from your kernel is the same with me, but it still occurred error on my local environment. However, if my problem is from the local environment, why it will succeed when I run the FCOS demo with my same dataset?

innat commented 4 years ago

@Eurus-Holmes That's really weird. What's your OS? Have you tried on Colab or on different PC (just for experimental purposes)?

I've just googled it and it looks like there's some issue with detectorn2, it may not some major issue but need something to care. Have you looked at this thread?

Eurus-Holmes commented 4 years ago

@innat Thanks for your help! Following this thread, I have solved it!

rm -r build/
pip uninstall detectron2
python -m pip install detectron2 -f   https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/torch1.5/index.html
python setup.py build develop

Thank you so much!

Yuliang-Liu commented 4 years ago

@innat @Eurus-Holmes Awesome

yizt commented 4 years ago

Are you trying with CPU? I think, in order to run ABCNet, you need GPU to compile and run.

No, I'm trying with GPU.

>>> import torch
>>> print("torch.cuda.is_available() =", torch.cuda.is_available())
torch.cuda.is_available() = True
>>> print("torch.backends.cudnn.is_available() =", torch.backends.cudnn.is_available())
torch.backends.cudnn.is_available() = True
>>> print("torch.rand(2, 3).cuda() =", torch.rand(2, 3).cuda())
torch.rand(2, 3).cuda() = tensor([[0.7986, 0.8999, 0.7932],
        [0.8926, 0.6369, 0.9564]], device='cuda:0')

@Eurus-Holmes I have met the same problem, how did you sovle it?

Eurus-Holmes commented 4 years ago

@innat Thanks for your help! Following this thread, I have solved it!

rm -r build/
pip uninstall detectron2
python -m pip install detectron2 -f   https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/torch1.5/index.html
python setup.py build develop

Thank you so much!

@yizt Please refer to this.