# Beam\_search bottlenecks inference with only 1 used cpu

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fbeam-search-bottlenecks-inference-with-only-1-used-cpu%2F24315%3E%5C
**Category:** 🤗Transformers\
**Created:** [October 12, 2022, 7:48am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fbeam-search-bottlenecks-inference-with-only-1-used-cpu%2F24315 "2022-10-12T07:48:18Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![adelplace](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/adelplace/32/12037_2.png) [@adelplace](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fadelplace)%5C
**Post date:** [October 13, 2022, 12:06pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fbeam-search-bottlenecks-inference-with-only-1-used-cpu%2F24315%2F2 "2022-10-13T12:06:01Z")

</div>

It seems like I am not the only one facing this problem :

> [@Model.generate() is extremely slow while using beam search](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodel-generate-is-extremely-slow-while-using-beam-search%2F6915)%3A
>
> I was previously using trainer.predict() to run my inference but it does not offer that much flexibility and control over generation. For instance, I want to have more than one generation for each sample and it is not possible with trainer.predict(). So I changed to model.generate(). The problem is now I have to handle batching on my own and can not really use multiple GPUs. Still, I feel like it can not be that slow even under these circumstances. Below I have a small code snippet that does the…

Any ideas of solution ? 🙂

---

_[View the full topic](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fbeam-search-bottlenecks-inference-with-only-1-used-cpu%2F24315)._
