# OOM when allocating using BERT

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Foom-when-allocating-using-bert%2F13496%3E%5C
**Category:** Beginners\
**Created:** [January 8, 2022, 7:55pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Foom-when-allocating-using-bert%2F13496 "2022-01-08T19:55:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![toyl](https://avatars.discourse-cdn.com/v4/letter/t/73ab20/32.png) [@toyl](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ftoyl)%5C
**Post date:** [January 8, 2022, 7:55pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Foom-when-allocating-using-bert%2F13496%2F1 "2022-01-08T19:55:24Z")

</div>

i got this problem with using embedding for 150.000 sentences using BERT model  
`tensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocating tensor with shape[1619381,768] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc [Op:RandomUniform]`

as the layer of embedding is  
` embed = Embedding(1619381, 768, mask_zero=True)(sentence)`  
i got this number **1619381** from `embeddings = torch.cat(embeddings,dim=0)`  
which contains all embedding for 150.000 sentences .

---

<div class="post-metadata">

**Author:** ![toyl](https://avatars.discourse-cdn.com/v4/letter/t/73ab20/32.png) [@toyl](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ftoyl)%5C
**Post date:** [February 5, 2022, 12:45am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Foom-when-allocating-using-bert%2F13496%2F2 "2022-02-05T00:45:59Z")

</div>

is there any help please
