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

After installing docline using pip while trying the sample code- its giving torch transformer compatibility issue #715

Open
PanchamiPrasannakumar opened this issue Jan 9, 2025 · 7 comments
Labels
bug Something isn't working

Comments

@PanchamiPrasannakumar
Copy link

Bug

ng_rt_detr.py", line 1597, in wrapper
if not torch.compiler.is_compiling():
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'torch.compiler' has no attribute 'is_compiling'

@PanchamiPrasannakumar PanchamiPrasannakumar added the bug Something isn't working label Jan 9, 2025
@trinanjan12
Copy link

trinanjan12 commented Jan 9, 2025

@PanchamiPrasannakumar have you tried this? 672

@PanchamiPrasannakumar
Copy link
Author

PanchamiPrasannakumar commented Jan 9, 2025

image getting numpy issue while trying that solution. I have used $ python3.12 -m venv venv $ source ./venv/bin/activate $ pip install --no-cache docling

$ docling --version
Docling version: 2.14.0

@trinanjan12
Copy link

Not sure @PanchamiPrasannakumar . I was doing something like this #653 (comment)

@dolfim-ibm
Copy link
Contributor

You could check pip show torch to verify which version was installed.

@PanchamiPrasannakumar
Copy link
Author

Name: torch
Version: 2.2.2

@dolfim-ibm
Copy link
Contributor

I think your architecture is no longer supported by the recent torch releases (we are now at 2.5.2).

You could try installing numpy 1.x explicitly.

pip install "numpy<2.0.0"

@gmeghnag
Copy link

gmeghnag commented Jan 9, 2025

I have the same issue here:

# python3 --version
Python 3.11.8

# python3 -m pip freeze | egrep -i "docling|numpy|torch"
docling==2.15.0
docling-core==2.13.1
docling-ibm-models==3.1.0
docling-parse==3.0.0
numpy==1.26.4
torch==2.2.2
torchvision==0.17.2
# cat ex.py 
from docling.document_converter import DocumentConverter
source = "https://arxiv.org/pdf/2408.09869"  # document per local path or URL
converter = DocumentConverter()
result = converter.convert(source)
print(result.document.export_to_markdown())
# python3 ex.py 
Encountered an error during conversion of document 82dd470712ce8389f19f20eb9330475e2166a281f8c7990a9f1d0763d73b4d22:
Traceback (most recent call last):

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/docling/pipeline/base_pipeline.py", line 150, in _build_document
    for p in pipeline_pages:  # Must exhaust!

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/docling/pipeline/base_pipeline.py", line 116, in _apply_on_pages
    yield from page_batch

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/docling/models/page_assemble_model.py", line 60, in __call__
    for page in page_batch:

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/docling/models/table_structure_model.py", line 136, in __call__
    for page in page_batch:

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/docling/models/layout_model.py", line 187, in __call__
    for ix, pred_item in enumerate(

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 35, in generator_context
    response = gen.send(None)
               ^^^^^^^^^^^^^^

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/docling_ibm_models/layoutmodel/layout_predictor.py", line 143, in predict
    outputs = self._model(**inputs)
              ^^^^^^^^^^^^^^^^^^^^^

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/transformers/models/rt_detr/modeling_rt_detr.py", line 2094, in forward
    outputs = self.model(
              ^^^^^^^^^^^

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/transformers/models/rt_detr/modeling_rt_detr.py", line 1886, in forward
    anchors, valid_mask = self.generate_anchors(spatial_shapes_tuple, device=device, dtype=dtype)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/transformers/models/rt_detr/modeling_rt_detr.py", line 1597, in wrapper
    if not torch.compiler.is_compiling():
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^

AttributeError: module 'torch.compiler' has no attribute 'is_compiling'

Traceback (most recent call last):
  File "/Users/gmeghnag/ex.py", line 4, in <module>
    result = converter.convert(source)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pydantic/_internal/_validate_call.py", line 38, in wrapper_function
    return wrapper(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pydantic/_internal/_validate_call.py", line 111, in __call__
    res = self.__pydantic_validator__.validate_python(pydantic_core.ArgsKwargs(args, kwargs))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/docling/document_converter.py", line 191, in convert
    return next(all_res)
           ^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/docling/document_converter.py", line 212, in convert_all
    for conv_res in conv_res_iter:
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/docling/document_converter.py", line 247, in _convert
    for item in map(
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/docling/document_converter.py", line 288, in _process_document
    conv_res = self._execute_pipeline(in_doc, raises_on_error=raises_on_error)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/docling/document_converter.py", line 311, in _execute_pipeline
    conv_res = pipeline.execute(in_doc, raises_on_error=raises_on_error)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/docling/pipeline/base_pipeline.py", line 52, in execute
    raise e
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/docling/pipeline/base_pipeline.py", line 44, in execute
    conv_res = self._build_document(conv_res)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/docling/pipeline/base_pipeline.py", line 178, in _build_document
    raise e
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/docling/pipeline/base_pipeline.py", line 150, in _build_document
    for p in pipeline_pages:  # Must exhaust!
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/docling/pipeline/base_pipeline.py", line 116, in _apply_on_pages
    yield from page_batch
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/docling/models/page_assemble_model.py", line 60, in __call__
    for page in page_batch:
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/docling/models/table_structure_model.py", line 136, in __call__
    for page in page_batch:
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/docling/models/layout_model.py", line 187, in __call__
    for ix, pred_item in enumerate(
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 35, in generator_context
    response = gen.send(None)
               ^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/docling_ibm_models/layoutmodel/layout_predictor.py", line 143, in predict
    outputs = self._model(**inputs)
              ^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/transformers/models/rt_detr/modeling_rt_detr.py", line 2094, in forward
    outputs = self.model(
              ^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/transformers/models/rt_detr/modeling_rt_detr.py", line 1886, in forward
    anchors, valid_mask = self.generate_anchors(spatial_shapes_tuple, device=device, dtype=dtype)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/transformers/models/rt_detr/modeling_rt_detr.py", line 1597, in wrapper
    if not torch.compiler.is_compiling():
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'torch.compiler' has no attribute 'is_compiling'

The O.S. is macOS Sequoia 15.1.1 Chip Apple M1 Pro and the Terminal is "open with Rosetta" [1].

[1] https://support.apple.com/en-in/102527

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants