# Why does all my gpu memory get used with a small model?

**URL:** <https://discuss.huggingface.co/t/why-does-all-my-gpu-memory-get-used-with-a-small-model/15390>\
**Category:** Beginners\
**Created:** [March 5, 2022, 6:50pm UTC](https://discuss.huggingface.co/t/why-does-all-my-gpu-memory-get-used-with-a-small-model/15390 "2022-03-05T18:50:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![imranq](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@imranq](https://discuss.huggingface.co/u/imranq)\
**Post date:** [March 5, 2022, 6:50pm UTC](https://discuss.huggingface.co/t/why-does-all-my-gpu-memory-get-used-with-a-small-model/15390/1 "2022-03-05T18:50:04Z")

</div>

I’m using colab pro to try out a few huggingface models, but even loading a 2gb model completely fills up the GPU memory (Tesla 16gb) and then as the data loads i frequently run out of memory. Can anyone explain why a small model will maximize gpu memory?

My dataset size is about 1gb between train and test if that makes a difference

---

<div class="post-metadata">

**Author:** ![anwarika](https://avatars.discourse-cdn.com/v4/letter/a/e0b2c6/32.png) [@anwarika](https://discuss.huggingface.co/u/anwarika)\
**Post date:** [March 7, 2022, 12:40am UTC](https://discuss.huggingface.co/t/why-does-all-my-gpu-memory-get-used-with-a-small-model/15390/2 "2022-03-07T00:40:54Z")

</div>

I can’t say for sure without seeing how you are running it. Can you troubleshoot and see whats running on your gpu?

---

<div class="post-metadata">

**Author:** ![imranq](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@imranq](https://discuss.huggingface.co/u/imranq)\
**Post date:** [March 12, 2022, 5:22pm UTC](https://discuss.huggingface.co/t/why-does-all-my-gpu-memory-get-used-with-a-small-model/15390/3 "2022-03-12T17:22:38Z")

</div>

Thanks! Do you know how I can see what processes are running in the terminal?

---

<div class="post-metadata">

**Author:** ![anwarika](https://avatars.discourse-cdn.com/v4/letter/a/e0b2c6/32.png) [@anwarika](https://discuss.huggingface.co/u/anwarika)\
**Post date:** [March 13, 2022, 2:11pm UTC](https://discuss.huggingface.co/t/why-does-all-my-gpu-memory-get-used-with-a-small-model/15390/4 "2022-03-13T14:11:04Z")

</div>

Can you supply your parameters on how you are training? ie batchsize, epochs, etc. I have run into memory issues with 1gb model, 2gb is actually pretty big when training.

To check gpu resources in googlecolab you can try something like this

```auto
#On the left side you can open Terminal ('>_' with black background)

#You can run commands from there even when some cell is running

#Write command to see GPU usage in real-time:

$ watch nvidia-smi

```

---

<div class="post-metadata">

**Author:** ![imranq](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@imranq](https://discuss.huggingface.co/u/imranq)\
**Post date:** [March 13, 2022, 2:54pm UTC](https://discuss.huggingface.co/t/why-does-all-my-gpu-memory-get-used-with-a-small-model/15390/5 "2022-03-13T14:54:51Z")

</div>

Thanks! I will try that out

---

<div class="post-metadata">

**Author:** ![BramVanroy](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/bramvanroy/32/47360_2.png) [@BramVanroy](https://discuss.huggingface.co/u/BramVanroy)\
**Post date:** [March 13, 2022, 7:20pm UTC](https://discuss.huggingface.co/t/why-does-all-my-gpu-memory-get-used-with-a-small-model/15390/6 "2022-03-13T19:20:09Z")

</div>

Are you using Tensorflow? By default it allocates all the available GPU memory. There are [ways around that though](https://stackoverflow.com/questions/34199233/how-to-prevent-tensorflow-from-allocating-the-totality-of-a-gpu-memory).
