# Train Mask2Former model using Trainer class

**URL:** <https://discuss.huggingface.co/t/train-mask2former-model-using-trainer-class/64002>\
**Category:** 🤗Transformers\
**Created:** [November 29, 2023, 3:44pm UTC](https://discuss.huggingface.co/t/train-mask2former-model-using-trainer-class/64002 "2023-11-29T15:44:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![student101](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@student101](https://discuss.huggingface.co/u/student101)\
**Post date:** [November 29, 2023, 3:44pm UTC](https://discuss.huggingface.co/t/train-mask2former-model-using-trainer-class/64002/1 "2023-11-29T15:44:16Z")

</div>

Hey guys,

I created a Mask2Former model following this notebook [here](https://github.com/NielsRogge/Transformers-Tutorials/blob/master/MaskFormer/Fine-tuning/Fine_tune_MaskFormer_on_an_instance_segmentation_dataset_(ADE20k_full).ipynb) for finetuning on my custom dataset. Since the model is too big to run on a single GPU I want to use multiple GPUs (I have a total of 4 GPUs available). The easiest solution I found was to use the Trainer class for this problem. Is that correct?

If so, my question would be: How can I add the Trainer class to my model and use it for training?  
Which steps do I need to do if my code is based on the above mentioned notebook?  
I am quite new to Huggingface, so please be patient with me 😊 …

Any help is appreciated. Thank you so much.
