I’m facing issues while running an OCR process using Nougat with two different errors for two different users. The errors are related to importing cached_property
and an unexpected keyword argument cache_position
. Below are the full error messages for both cases:
Error 1: ImportError for cached_property
ImportError: cannot import name 'cached_property' from 'nougat.utils' (/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/utils/__init__.py)
OCRing with base model failed on /lfs/skampere1/0/emilyhyf/massive-evaporation-4-math/data/debug_pdfs/dummy_folder1/The_IMO_Compendium.pdf... trying small model
Traceback (most recent call last):
File "/lfs/skampere1/0/emilyhyf/miniconda/bin/nougat", line 5, in <module>
from predict import main
File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/predict.py", line 18, in <module>
from nougat import NougatModel
File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/__init__.py", line 1, in <module>
from nougat.app import Nougat
File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/app.py", line 5, in <module>
from nougat.asgi import serve
File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/asgi.py", line 6, in <module>
from nougat.context.request import Request
File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/context/__init__.py", line 1, in <module>
from nougat.context.request import Request
File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/context/request.py", line 8, in <module>
from nougat.utils import cached_property, File
ImportError: cannot import name 'cached_property' from 'nougat.utils' (/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/utils/__init__.py)
OCRing with small model failed on /lfs/skampere1/0/emilyhyf/massive-evaporation-4-math/data/debug_pdfs/dummy_folder1/The_IMO_Compendium.pdf
The following files failed OCRing and need manual review:
/lfs/skampere1/0/emilyhyf/massive-evaporation-4-math/data/debug_pdfs/putnam_and_beyond.pdf
/lfs/skampere1/0/emilyhyf/massive-evaporation-4-math/data/debug_pdfs/dummy_folder1/The_IMO_Compendium.pdf
Time taken: 8.497612476348877 seconds, 0.1416268746058146 minutes, 0.00236044791009691 hours
Error 2: TypeError for cache_position
in BARTDecoder
TypeError: BARTDecoder.prepare_inputs_for_inference() got an unexpected keyword argument 'cache_position'
-> Cannot close object, library is destroyed. This may cause a memory leak!
-> Cannot close object, library is destroyed. This may cause a memory leak!
-> Cannot close object, library is destroyed. This may cause a memory leak!
OCRing with base model failed on /lfs/skampere1/0/naveenkc/contest_scraper/test_nougat/731991.pdf... trying small model
/lfs/skampere1/0/naveenkc/miniconda/lib/python3.12/site-packages/torch/functional.py:512: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3587.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
0%| | 0/288 [00:24<?, ?it/s]
Traceback (most recent call last):
File "/lfs/skampere1/0/naveenkc/miniconda/bin/nougat", line 8, in <module>
sys.exit(main())
^^^^^^
File "/lfs/skampere1/0/naveenkc/miniconda/lib/python3.12/site-packages/predict.py", line 167, in main
model_output = model.inference(
^^^^^^^^^^^^^^^^
File "/lfs/skampere1/0/naveenkc/miniconda/lib/python3.12/site-packages/nougat/model.py", line 592, in inference
decoder_output = self.decoder.model.generate(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lfs/skampere1/0/naveenkc/miniconda/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/lfs/skampere1/0/naveenkc/miniconda/lib/python3.12/site-packages/transformers/generation/utils.py", line 1758, in generate
result = self._sample(
^^^^^^^^^^^^^
File "/lfs/skampere1/0/naveenkc/miniconda/lib/python3.12/site-packages/transformers/generation/utils.py", line 2394, in _sample
model_inputs = self.prepare_inputs_for_generation(input_ids, **model_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: BARTDecoder.prepare_inputs_for_inference() got an unexpected keyword argument 'cache_position'
-> Cannot close object, library is destroyed. This may cause a memory leak!
-> Cannot close object, library is destroyed. This may cause a memory leak!
-> Cannot close object, library is destroyed. This may cause a memory leak!
-> Cannot close object, library is destroyed. This may cause a memory leak!
-> Cannot close object, library is destroyed. This may cause a memory leak!
OCRing with small model failed on /lfs/skampere1/0/naveenkc/contest_scraper/test_nougat/731991.pdf
The following files failed OCRing and need manual review:
/lfs/skampere1/0/naveenkc/contest_scraper/test_nougat/731991.pdf
Time taken: 65.70022702217102 seconds, 1.0950037837028503 minutes, 0.018250063061714172 hours
Environment:
- Python 3.12
- Nougat
- Torch
- Transformers
Questions:
-
ImportError: How can I resolve the
ImportError: cannot import name 'cached_property' from 'nougat.utils'
? What could be causing this issue, and is there an alternative approach to importcached_property
? -
TypeError: How can I address the
TypeError: BARTDecoder.prepare_inputs_for_inference() got an unexpected keyword argument 'cache_position'
? Is this due to a version mismatch betweentransformers
andtorch
? How can I ensure compatibility?
Any guidance on these issues would be greatly appreciated! Thank you in advance!
I’m facing issues while running an OCR process using Nougat with two different errors for two different users. The errors are related to importing cached_property
and an unexpected keyword argument cache_position
. Below are the full error messages for both cases:
Error 1: ImportError for cached_property
ImportError: cannot import name 'cached_property' from 'nougat.utils' (/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/utils/__init__.py)
OCRing with base model failed on /lfs/skampere1/0/emilyhyf/massive-evaporation-4-math/data/debug_pdfs/dummy_folder1/The_IMO_Compendium.pdf... trying small model
Traceback (most recent call last):
File "/lfs/skampere1/0/emilyhyf/miniconda/bin/nougat", line 5, in <module>
from predict import main
File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/predict.py", line 18, in <module>
from nougat import NougatModel
File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/__init__.py", line 1, in <module>
from nougat.app import Nougat
File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/app.py", line 5, in <module>
from nougat.asgi import serve
File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/asgi.py", line 6, in <module>
from nougat.context.request import Request
File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/context/__init__.py", line 1, in <module>
from nougat.context.request import Request
File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/context/request.py", line 8, in <module>
from nougat.utils import cached_property, File
ImportError: cannot import name 'cached_property' from 'nougat.utils' (/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/utils/__init__.py)
OCRing with small model failed on /lfs/skampere1/0/emilyhyf/massive-evaporation-4-math/data/debug_pdfs/dummy_folder1/The_IMO_Compendium.pdf
The following files failed OCRing and need manual review:
/lfs/skampere1/0/emilyhyf/massive-evaporation-4-math/data/debug_pdfs/putnam_and_beyond.pdf
/lfs/skampere1/0/emilyhyf/massive-evaporation-4-math/data/debug_pdfs/dummy_folder1/The_IMO_Compendium.pdf
Time taken: 8.497612476348877 seconds, 0.1416268746058146 minutes, 0.00236044791009691 hours
Error 2: TypeError for cache_position
in BARTDecoder
TypeError: BARTDecoder.prepare_inputs_for_inference() got an unexpected keyword argument 'cache_position'
-> Cannot close object, library is destroyed. This may cause a memory leak!
-> Cannot close object, library is destroyed. This may cause a memory leak!
-> Cannot close object, library is destroyed. This may cause a memory leak!
OCRing with base model failed on /lfs/skampere1/0/naveenkc/contest_scraper/test_nougat/731991.pdf... trying small model
/lfs/skampere1/0/naveenkc/miniconda/lib/python3.12/site-packages/torch/functional.py:512: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3587.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
0%| | 0/288 [00:24<?, ?it/s]
Traceback (most recent call last):
File "/lfs/skampere1/0/naveenkc/miniconda/bin/nougat", line 8, in <module>
sys.exit(main())
^^^^^^
File "/lfs/skampere1/0/naveenkc/miniconda/lib/python3.12/site-packages/predict.py", line 167, in main
model_output = model.inference(
^^^^^^^^^^^^^^^^
File "/lfs/skampere1/0/naveenkc/miniconda/lib/python3.12/site-packages/nougat/model.py", line 592, in inference
decoder_output = self.decoder.model.generate(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lfs/skampere1/0/naveenkc/miniconda/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/lfs/skampere1/0/naveenkc/miniconda/lib/python3.12/site-packages/transformers/generation/utils.py", line 1758, in generate
result = self._sample(
^^^^^^^^^^^^^
File "/lfs/skampere1/0/naveenkc/miniconda/lib/python3.12/site-packages/transformers/generation/utils.py", line 2394, in _sample
model_inputs = self.prepare_inputs_for_generation(input_ids, **model_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: BARTDecoder.prepare_inputs_for_inference() got an unexpected keyword argument 'cache_position'
-> Cannot close object, library is destroyed. This may cause a memory leak!
-> Cannot close object, library is destroyed. This may cause a memory leak!
-> Cannot close object, library is destroyed. This may cause a memory leak!
-> Cannot close object, library is destroyed. This may cause a memory leak!
-> Cannot close object, library is destroyed. This may cause a memory leak!
OCRing with small model failed on /lfs/skampere1/0/naveenkc/contest_scraper/test_nougat/731991.pdf
The following files failed OCRing and need manual review:
/lfs/skampere1/0/naveenkc/contest_scraper/test_nougat/731991.pdf
Time taken: 65.70022702217102 seconds, 1.0950037837028503 minutes, 0.018250063061714172 hours
Environment:
- Python 3.12
- Nougat
- Torch
- Transformers
Questions:
-
ImportError: How can I resolve the
ImportError: cannot import name 'cached_property' from 'nougat.utils'
? What could be causing this issue, and is there an alternative approach to importcached_property
? -
TypeError: How can I address the
TypeError: BARTDecoder.prepare_inputs_for_inference() got an unexpected keyword argument 'cache_position'
? Is this due to a version mismatch betweentransformers
andtorch
? How can I ensure compatibility?
Any guidance on these issues would be greatly appreciated! Thank you in advance!