facebookresearch / nougat

Implementation of Nougat Neural Optical Understanding for Academic Documents
https://facebookresearch.github.io/nougat/
MIT License
8.76k stars 560 forks source link

Having issue on -> Cannot close object, library is destroyed. This may cause a memory leak! #222

Open MichaelOcampo1104 opened 4 months ago

MichaelOcampo1104 commented 4 months ago

working fine previously however recently, Im getting no ouputs with message -> Cannot close object, library is destroyed. This may cause a memory leak!, im using a colab notebook

Crestina2001 commented 3 months ago

Have you solved this yet?

isayahc commented 3 months ago

do you use nougat or predict.py?

I found a hacky way of solving it by adding del model_kwargs['cache_position'] into venv/lib/python3.12/site-packages/transformers/generation/utils.py after line 2390 which should be model_kwargs = self._get_initial_cache_position(input_ids, model_kwargs) then using predict.py such as predict.py sample_pdf -o output/

Additional Information

python version Python 3.12.2

transformers==4.41.1 pytorch-lightning==2.2.5 torch==2.3.0 torchmetrics==1.4.0.post0 torchvision==0.18.0

ELchem commented 3 months ago

this is an issue with pypdfium2.PdfDocument not being closed

shadi007 commented 3 months ago

i am using nougat in colab and it gives this error "Cannot close object, library is destroyed. This may cause a memory leak!" is there a way of solving or to use nougat but using predict.py i have no experience with coding

shadi007 commented 3 months ago

do you use nougat or predict.py?

I found a hacky way of solving it by adding del model_kwargs['cache_position'] into venv/lib/python3.12/site-packages/transformers/generation/utils.py then using predict.py

Additional Information

python version Python 3.12.2

transformers==4.41.1 pytorch-lightning==2.2.5 torch==2.3.0 torchmetrics==1.4.0.post0 torchvision==0.18.0

could you please explain in details how you use predict.py

shadi007 commented 3 months ago

Have you solved this yet?

did u find a solution to this problem

augustoximenes commented 3 months ago

Try:

pip install transformers==4.38.2

isayahc commented 3 months ago

do you use nougat or predict.py? I found a hacky way of solving it by adding del model_kwargs['cache_position'] into venv/lib/python3.12/site-packages/transformers/generation/utils.py then using predict.py

Additional Information

python version Python 3.12.2 transformers==4.41.1 pytorch-lightning==2.2.5 torch==2.3.0 torchmetrics==1.4.0.post0 torchvision==0.18.0

could you please explain in details how you use predict.py @shadi007 Here is a sample cli command i use predict.py sample_pdf -o output/

Also i will add more information in my first reponse.

ludwigax commented 3 months ago

This is a problem using the Transformer with versions later than 4.38.2.