# GPU memory that model uses

**URL:** <https://discuss.pytorch.org/t/gpu-memory-that-model-uses/56822>\
**Category:** Uncategorized\
**Created:** [September 25, 2019, 6:33pm UTC](https://discuss.pytorch.org/t/gpu-memory-that-model-uses/56822 "2019-09-25T18:33:35Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![blackbirdbarber](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/b/6de8d8/32.png) [@blackbirdbarber](https://discuss.pytorch.org/u/blackbirdbarber)\
**Post date:** [September 27, 2019, 5:58pm UTC](https://discuss.pytorch.org/t/gpu-memory-that-model-uses/56822/9 "2019-09-27T17:58:54Z")

</div>

Thanks, it was:

```auto
import torch
torch.cuda.max_memory_allocated()

```

This can help me figure out the max batch size I can use on a model, hopefully. But I wonder if something similar is present in PyTorch already.

However, I am not sure if this thing will also count the memory in the garbage collector that can be free after `gc.collect()`.

Maybe this is called [cache](https://discuss.pytorch.org/t/collecting-garbage-questions/56821).

---

_[View the full topic](https://discuss.pytorch.org/t/gpu-memory-that-model-uses/56822)._
