rsommerfeld / trocr

Powerful handwritten text recognition. A simple-to-use, unofficial implementation of the paper "TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models".
MIT License
176 stars 27 forks source link

Error trying to run the model (Runtime error CUDA out of memory) #1

Closed akiradavid27 closed 2 years ago

akiradavid27 commented 2 years ago

Hi, I've been struggling for a while trying to run your model, everytime I try to do so it shows the same error message. First, it showed error Win 1455, like this one: [WinError 1455] The paging file is too small for this operation to complete. Error loading "C:\ProgramData\Anaconda3\lib\site-packages\torch\lib\caffe2_detectron_ops_gpu.dll" or one of its dependencies.

After searching about it on the web, and modifying parameters I got, what it seems, another version of that same error: RuntimeError: CUDA out of memory. Tried to allocate 16.00 MiB (GPU 0; 6.00 GiB total capacity; 5.30 GiB already allocated; 0 bytes free; 5.35 GiB reserved in total by PyTorch) If reserved memory is allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

Do you have any idea how to manage this situation? Thanks

rsommerfeld commented 2 years ago

Hi akiradavid27, this error simply means that you are trying to allocate more GPU memory than your GPU has available. You could try lowering the batch size in configs/constants.py until it works.

In combination with lowering batch size, you could try replacing the trocr_repo constant of configs/paths.py with "trocr-small-handwritten".

Hope this helps!

akiradavid27 commented 2 years ago

Yes! It definately helped, I was able tu run the model. Thank you!

rsommerfeld commented 2 years ago

Great! 👍🏻