# Memory increasing after hugging face generate method

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmemory-increasing-after-hugging-face-generate-method%2F127208%3E%5C
**Category:** Models\
**Created:** [November 24, 2024, 3:15am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmemory-increasing-after-hugging-face-generate-method%2F127208 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsleepywalker)%5C
**Post date:** [November 24, 2024, 3:15am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmemory-increasing-after-hugging-face-generate-method%2F127208%2F1 "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)
