donut icon indicating copy to clipboard operation
donut copied to clipboard

Can the model be finetuned with 8 GB cuda memory?

Open inesriahi opened this issue 2 years ago • 8 comments

Thank you for this incredible model! As the title says, I have an 8 GB gpu, so is there a way to finetune the model locally? I have tried decreasing the input_shape to 1280x960. I assume this is the lowest value I can decrease it to as I read from the other issues. I set the train_batch_size to 1, too. So, would anyone provide me with more suggestions to fit my constraints? Thanks a ton.

inesriahi avatar Dec 05 '22 04:12 inesriahi

There is no offical code snipped in donut to facilitate the same Try incorporating the suggestions in the link here https://spell.ml/blog/gradient-checkpointing-pytorch-YGypLBAAACEAefHs

Let us know if it works

TheSeriousProgrammer avatar Dec 05 '22 05:12 TheSeriousProgrammer

@inesriahi reducing either of these parameters will help here: input_size: [2560, 1920] ---> [1920, 1280] or [1280, 960] or some lower value (you need to find a lower value where you are not getting any errors like 720, 960, 1080) max_length: 128 ---> 64 or 100

vishal-nayak1 avatar Dec 05 '22 08:12 vishal-nayak1

@inesriahi reducing either of these parameters will help here: input_size: [2560, 1920] ---> [1920, 1280] or [1280, 960] or some lower value (you need to find a lower value where you are not getting any errors like 720, 960, 1080) max_length: 128 ---> 64 or 100

Is there a lower input size value that doesn't produce errors?

inesriahi avatar Dec 12 '22 08:12 inesriahi

960x640 works, i guess that the input dimensions should be a multiple of 320

Going below this resolution might give junk, as the pdf might become pixelated and fonts not visible

TheSeriousProgrammer avatar Dec 26 '22 10:12 TheSeriousProgrammer

@inesriahi i'm facing issues running a simple inference of the model on an 8GB GPU. do you have a code snippet that does put the model to the device and does a simple inference please ?

AmineDjeghri avatar Mar 31 '23 18:03 AmineDjeghri

I was not able to run donut on 8GB VRAM, i think minimum is 12 GB and that using smaller input_size, on a 16GB card i get 80-90 % vram usage using input_size: [960, 960]

Wyzix33 avatar Apr 01 '23 18:04 Wyzix33

@Wyzix33 fixed ! The problem was Cudnn not being installed . It can run on 8gb vram ! I'm talking about inference of course, not fine tuning

AmineDjeghri avatar Apr 01 '23 19:04 AmineDjeghri

Try Reducing batch size to 1

sudhitpanchal avatar Oct 16 '23 07:10 sudhitpanchal