# Using Transformers with DistributedDataParallel — any examples?

**URL:** <https://discuss.huggingface.co/t/using-transformers-with-distributeddataparallel-any-examples/10775>\
**Category:** Intermediate\
**Created:** [October 14, 2021, 2:33pm UTC](https://discuss.huggingface.co/t/using-transformers-with-distributeddataparallel-any-examples/10775 "2021-10-14T14:33:51Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![treeofknowledge](https://avatars.discourse-cdn.com/v4/letter/t/2acd7d/32.png) [@treeofknowledge](https://discuss.huggingface.co/u/treeofknowledge)\
**Post date:** [October 15, 2021, 12:45pm UTC](https://discuss.huggingface.co/t/using-transformers-with-distributeddataparallel-any-examples/10775/3 "2021-10-15T12:45:33Z")

</div>

Introduction for the `Accelerate` library says I have to be willing to write a forward loop (forgoing Trainer). Is there a way for me to enable DDP training while continuing using Trainer?

Replacing `_get_train_sampler` with `_get_eval_sampler` looks like a much more elegant solution, thank you!

---

_[View the full topic](https://discuss.huggingface.co/t/using-transformers-with-distributeddataparallel-any-examples/10775)._
