# How to save model in S3 with Trainer?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-save-model-in-s3-with-trainer%2F15927%3E%5C
**Category:** Intermediate\
**Created:** [March 21, 2022, 9:06pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-save-model-in-s3-with-trainer%2F15927 "2022-03-21T21:06:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndriiP](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@AndriiP](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FAndriiP)%5C
**Post date:** [March 21, 2022, 9:06pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-save-model-in-s3-with-trainer%2F15927%2F1 "2022-03-21T21:06:51Z")

</div>

When I do  
Trainer.save\_model(‘s3://path\_to\_folder’)

I got no error with message  
Saving model checkpoint to s3://path\_to\_folder  
Configuration saved in s3://path\_to\_folder/config.json  
Model weights saved in s3://path\_to\_folder/pytorch\_model.bin  
tokenizer config file saved in s3://path\_to\_folder/tokenizer\_config.json  
Special tokens file saved in s3://path\_to\_folder/special\_tokens\_map.json

But corresponding folder in S3 is empty.  
How correctly save model in S3 with Trainer.save\_model?

---

<div class="post-metadata">

**Author:** ![tyatabe](https://avatars.discourse-cdn.com/v4/letter/t/3e96dc/32.png) [@tyatabe](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ftyatabe)%5C
**Post date:** [August 17, 2022, 1:41pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-save-model-in-s3-with-trainer%2F15927%2F2 "2022-08-17T13:41:20Z")

</div>

Hey @AndriiP did you figure this out? I have a similar issue. I’m running from a Sagemaker notebook instance and it seems to be saving the files as per the log being printed, but the s3 bucket is empty

Thank you

---

<div class="post-metadata">

**Author:** ![AndriiP](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@AndriiP](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FAndriiP)%5C
**Post date:** [August 17, 2022, 2:02pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-save-model-in-s3-with-trainer%2F15927%2F3 "2022-08-17T14:02:29Z")

</div>

Hi [tyatabe](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ftyatabe)%2C

I did not find the right solution.  
I just zip checkpoint folder, save on S3, when needed load, unzip and use it.

---

<div class="post-metadata">

**Author:** ![tyatabe](https://avatars.discourse-cdn.com/v4/letter/t/3e96dc/32.png) [@tyatabe](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ftyatabe)%5C
**Post date:** [August 18, 2022, 1:53pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-save-model-in-s3-with-trainer%2F15927%2F4 "2022-08-18T13:53:59Z")

</div>

Thank you @AndriiP I ended up doing something along the same lines. I found comfort in knowing I wasn’t the only one with this issue 🙂

---

<div class="post-metadata">

**Author:** ![Pelps](https://avatars.discourse-cdn.com/v4/letter/p/65b543/32.png) [@Pelps](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FPelps)%5C
**Post date:** [May 25, 2023, 4:28pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-save-model-in-s3-with-trainer%2F15927%2F5 "2023-05-25T16:28:28Z")

</div>

I believe you could use TrainerCallback to send it to S3 on\_save

> **[Callbacks](https://huggingface.co/docs/transformers/v4.29.1/en/main_classes/callback#transformers.TrainerCallback)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

---

<div class="post-metadata">

**Author:** ![Guldeniz](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/guldeniz/32/16355_2.png) [@Guldeniz](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FGuldeniz)%5C
**Post date:** [May 26, 2023, 11:42am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-save-model-in-s3-with-trainer%2F15927%2F6 "2023-05-26T11:42:54Z")

</div>

To use trained models in Sagemaker you can use Sagemaker Training Job. It will train and upload `.tar.gz` model to S3 for you to use. See here for more:

> **[Run training on Amazon SageMaker](https://huggingface.co/docs/sagemaker/train)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.
