EasyOCR icon indicating copy to clipboard operation
EasyOCR copied to clipboard

deform_conv_cuda not found in deform_conv

Open Mahmuod1 opened this issue 2 years ago • 7 comments

Screenshot from 2022-08-25 15-01-56

Mahmuod1 avatar Aug 25 '22 13:08 Mahmuod1

I met same issue trying initializing reader = easyocr.Reader(["en", "de"], detect_network="dbnet18")

File ~/.virtualenvs/py3106/lib/python3.10/site-packages/easyocr/DBNet/assets/ops/dcn/functions/deform_conv.py:5, in <module>
      2 from torch.autograd import Function
      3 from torch.nn.modules.utils import _pair
----> 5 from .. import deform_conv_cuda
      8 class DeformConvFunction(Function):
     10     @staticmethod
     11     def forward(ctx,
     12                 input,
   (...)
     19                 deformable_groups=1,
     20                 im2col_step=64):

ImportError: cannot import name 'deform_conv_cuda' from partially initialized module 'easyocr.DBNet.assets.ops.dcn' (most likely due to a circular import) 

purplesword avatar Aug 29 '22 19:08 purplesword

I've tried various combinations with

  • python 3.7/3.8/3.9/3.10,
  • torch 1.7/1.9/1.10/1.12,
  • cuda 10.1/11.3/11.6/11.7,
  • ubuntu 20.04/22.04,
  • via pip instal easyocr/with python compile_dbnet_dcn.py.

Unfortunately all of them failed at this step.

Anyone managed to get it running? Could you share you env setting and lib versions?

purplesword avatar Aug 30 '22 14:08 purplesword

Encountered the same issue

timchann124 avatar Aug 31 '22 05:08 timchann124

Update: I got it work. The key is:

  • nvcc is necessary, so cuda runtime image as base image is not enough. It must be cuda-devel.
  • env var CUDA_HOME must be set. It's not enough to have nvcc present under PATH. So set /usr/local/cuda... as CUDA_HOME is a must.
  • After pip install easyocr, I still need to go to path/to/lib/easyocr/scripts and run python compile_dbnet_dcn.py. If the above 2 conditions met, this time it works. No matter what cuda/os/torch version combination.

Unfortunately for my use case it seems the shared dbnet18 model works worse than craft (although craft is not perfect either).

purplesword avatar Aug 31 '22 13:08 purplesword

Same error here.

ogencoglu avatar Aug 31 '22 21:08 ogencoglu

Same issue.

dilerbatu avatar Sep 12 '22 13:09 dilerbatu

hi all, can you try the last version (1.6.2)?

rkcosmos avatar Sep 17 '22 06:09 rkcosmos

thanx it is work

Mahmuod1 avatar Sep 25 '22 09:09 Mahmuod1

I solved it with conda install cuda-nvcc

nguyenvulong avatar Jul 04 '24 08:07 nguyenvulong