# Models is not saved in S3 bucket location

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodels-is-not-saved-in-s3-bucket-location%2F80861%3E%5C
**Category:** Amazon SageMaker\
**Created:** [April 9, 2024, 9:46am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodels-is-not-saved-in-s3-bucket-location%2F80861 "2024-04-09T09:46:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![amtha24](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@amtha24](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Famtha24)%5C
**Post date:** [April 9, 2024, 9:46am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmodels-is-not-saved-in-s3-bucket-location%2F80861%2F1 "2024-04-09T09:46:35Z")

</div>

import time  
import json  
from sagemaker.huggingface import HuggingFace

# define Training Job Name

job\_name = f’huggingface-donut-{time.strftime(“%Y-%m-%d-%H-%M-%S”, time.localtime())}’

# stingify special tokens

special\_tokens = ‘,’.join(map(str, processor.tokenizer.special\_tokens\_map\_extended[“additional\_special\_tokens”]))  
training\_input\_path = f’s3://processed/donut-sagemaker/train’

# hyperparameters, which are passed into the training job

hyperparameters = {  
‘model\_id’: model\_id, # pre-trained model  
‘special\_tokens’: json.dumps(special\_tokens), # special tokens which will be added to the tokenizer  
‘dataset\_path’: training\_input\_path, # path where sagemaker will save training dataset  
‘epochs’: 1, # number of training epochs  
‘per\_device\_train\_batch\_size’: 8, # batch size for training  
‘gradient\_checkpointing’: True, # batch size for training  
‘lr’: 4e-5, # learning rate used during training  
}

# create the Estimator

huggingface\_estimator = HuggingFace(  
entry\_point = ‘train.py’, # train script  
source\_dir = ‘./scripts’, # directory which includes all the files needed for training  
instance\_type = ‘ml.p3.2xlarge’, # instances type used for the training job  
output\_path = “s3://processed/donut-sagemaker/path/”,  
code\_location = “s3://processed/donut-sagemaker/code/”,  
instance\_count = 1, # the number of instances used for training  
base\_job\_name = job\_name, # the name of the training job  
role = role, # Iam role used in training job to access AWS ressources, e.g. S3  
volume\_size = 100, # the size of the EBS volume in GB  
transformers\_version = ‘4.26’, # the transformers version used in the training job  
pytorch\_version = ‘1.13’, # the pytorch\_version version used in the training job  
py\_version = ‘py39’, # the python version used in the training job  
hyperparameters = hyperparameters  
)

# define a data input dictonary with our uploaded s3 uris

data = {‘training’: training\_input\_path}

# starting the train job with our uploaded datasets as input

huggingface\_estimator.fit(data, wait=True)

```
model.save_pretrained("s3://processed/donut-sagemaker/model/")
processor.save_pretrained("s3://processed/donut-sagemaker/model/")

```

I am trying run this training on sagemaker pipeline , the training is success but my models is not saved in that location can anyone help me to resolve it?
