# Memory increasing after hugging face generate method

**URL:** <https://discuss.huggingface.co/t/memory-increasing-after-hugging-face-generate-method/127208>\
**Category:** Models\
**Created:** [November 24, 2024, 3:15am UTC](https://discuss.huggingface.co/t/memory-increasing-after-hugging-face-generate-method/127208 "2024-11-24T03:15:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sleepywalker](https://avatars.discourse-cdn.com/v4/letter/s/6f9a4e/32.png) [@sleepywalker](https://discuss.huggingface.co/u/sleepywalker)\
**Post date:** [November 24, 2024, 3:15am UTC](https://discuss.huggingface.co/t/memory-increasing-after-hugging-face-generate-method/127208/1 "2024-11-24T03:15:13Z")

</div>

Hello! I wanted to make an inference with codegemma model from huggingface, but when I use model.generate(\*\*inputs) method GPU memory cost increases from 39 GB to 49 GB in peak usage with torch profiler no matter max\_token\_len number. I understand that we need to save activations of model on inference and context of like 4096 input tokens but I can’t believe that it can increase inference memory usage on 10 GB. Can someone explain me how could it be? Thank you in advance.  
P.S. I attached below profiler of input of 330, 2700 and 8600 tokens respectively

 ![Снимок экрана 2024-11-24 в 06.02.56](https://us1.discourse-cdn.com/hellohellohello/original/3X/8/3/831d17b7e57203f680a6395db111617d6f12aac8.jpeg)
