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

Error importing Detection model on Kaggle Notebooks: Torch and Cuda incompatibility #253

Closed
iaminebriki opened this issue Nov 28, 2024 · 1 comment

Comments

@iaminebriki
Copy link

iaminebriki commented Nov 28, 2024

I have installed surya-ocr with pip on Kaggle notebook and I'm getting this error when I try to import the Detection model which I suppose has something to do with Torch version?

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[11], line 2
      1 # ---------- detection ----------
----> 2 from surya.model.detection.model import load_model as load_det_model, load_processor as load_det_processor
      3 # ---------- layout ----------
      4 # from surya.detection import batch_text_detection
      5 # from surya.layout import batch_layout_detection
   (...)
     10 # from surya.model.ordering.processor import load_processor as ord_processor
     11 # ---------- ocr ----------
     12 from surya.ocr import run_ocr

File /opt/conda/lib/python3.10/site-packages/surya/model/detection/model.py:14
     11 from typing import Optional, Union, Tuple, List, Any
     12 from functools import partial
---> 14 import torch
     15 import torch.nn as nn
     16 import torch.nn.functional as F

File /opt/conda/lib/python3.10/site-packages/torch/__init__.py:367
    365     if USE_GLOBAL_DEPS:
    366         _load_global_deps()
--> 367     from torch._C import *  # noqa: F403
    370 class SymInt:
    371     """
    372     Like an int (including magic methods), but redirects all operations on the
    373     wrapped node. This is used in particular to symbolically record operations
    374     in the symbolic shape workflow.
    375     """

ImportError: /opt/conda/lib/python3.10/site-packages/torch/lib/../../nvidia/cusparse/lib/libcusparse.so.12: undefined symbol: __nvJitLinkComplete_12_4, version libnvJitLink.so.12
@iaminebriki iaminebriki changed the title Error importing Detection model: Torch and Cuda incompatibility Error importing Detection model on Kaggle Notebooks: Torch and Cuda incompatibility Nov 28, 2024
@iaminebriki
Copy link
Author

For anyone faced with same issue, here is a workaround:

  1. Install Surya in a separate env:
!mkdir my_env
!pip install --target=my_env surya-ocr
  1. Add that env to PATH:
import sys
sys.path.append("my_env")
import surya

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