# Trainer .train (resume \_from \_checkpoint =True)

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftrainer-train-resume-from-checkpoint-true%2F13118%3E%5C
**Category:** Beginners\
**Created:** [December 25, 2021, 1:01am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftrainer-train-resume-from-checkpoint-true%2F13118 "2021-12-25T01:01:23Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![maher13](https://avatars.discourse-cdn.com/v4/letter/m/3ec8ea/32.png) [@maher13](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmaher13)%5C
**Post date:** [December 25, 2021, 1:01am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftrainer-train-resume-from-checkpoint-true%2F13118%2F1 "2021-12-25T01:01:23Z")

</div>

Hi all,

I’m trying to resume my training from a checkpoint  
my training argument:  
training\_args = TrainingArguments(

output\_dir=repo\_name,  
group\_by\_length=True,  
per\_device\_train\_batch\_size=16,  
per\_device\_eval\_batch\_size=1,  
gradient\_accumulation\_steps=8,  
evaluation\_strategy=“steps”,  
num\_train\_epochs=50,  
fp16=True,  
save\_steps=500,  
eval\_steps=400,  
logging\_steps=10,  
learning\_rate=5e-4,  
warmup\_steps=3000,  
push\_to\_hub=True,  
)

my trainer:  
trainer = Trainer(  
model=model,  
data\_collator=data\_collator,  
args=training\_args,  
compute\_metrics=compute\_metrics,  
train\_dataset=common\_voice\_train,  
eval\_dataset=common\_voice\_test,  
tokenizer=processor.feature\_extractor,  
)

till here everything is fine

then my training command :  
trainer.train(resume\_from\_checkpoint=True)

the error is:  
----\> 1 trainer.train(resume\_from\_checkpoint=True)

/opt/conda/lib/python3.7/site-packages/transformers/trainer.py in train(self, resume\_from\_checkpoint, trial, ignore\_keys\_for\_eval, \*\*kwargs)  
1073 resume\_from\_checkpoint = get\_last\_checkpoint(args.output\_dir)  
1074 if resume\_from\_checkpoint is None:  
 → 1075 raise ValueError(f"No valid checkpoint found in output directory ({args.output\_dir})")  
1076  
1077 if resume\_from\_checkpoint is not None:

ValueError: No valid checkpoint found in output directory (stt-arabic-2)

any thought why ??

---

<div class="post-metadata">

**Author:** ![bengul](https://avatars.discourse-cdn.com/v4/letter/b/838e76/32.png) [@bengul](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fbengul)%5C
**Post date:** [December 25, 2021, 3:42pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftrainer-train-resume-from-checkpoint-true%2F13118%2F2 "2021-12-25T15:42:51Z")

</div>

> [@maher13](#):
>
> trainer.train(resume\_from\_checkpoint=True)

Probably you need to check if the models are saving in the checkpoint directory, You can also provide the checkpoint directory in the resume\_from\_checkpoint=‘checkpoint\_dir’

---

<div class="post-metadata">

**Author:** ![maher13](https://avatars.discourse-cdn.com/v4/letter/m/3ec8ea/32.png) [@maher13](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmaher13)%5C
**Post date:** [December 28, 2021, 11:44am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftrainer-train-resume-from-checkpoint-true%2F13118%2F3 "2021-12-28T11:44:18Z")

</div>

can i push the checkpoints to huggingface hub ??

---

<div class="post-metadata">

**Author:** ![merve](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/merve/32/49809_2.png) [@merve](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmerve)%5C
**Post date:** [December 29, 2021, 5:16am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftrainer-train-resume-from-checkpoint-true%2F13118%2F4 "2021-12-29T05:16:08Z")

</div>

Welcome @maher13 🤗 Have you tried the above answer (which seems to me is the right one).  
There are multiple ways of pushing your model to hub, see more about it [here](https://huggingface.co/docs/transformers/model_sharing).

---

<div class="post-metadata">

**Author:** ![maher13](https://avatars.discourse-cdn.com/v4/letter/m/3ec8ea/32.png) [@maher13](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmaher13)%5C
**Post date:** [March 7, 2022, 11:49am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftrainer-train-resume-from-checkpoint-true%2F13118%2F5 "2022-03-07T11:49:24Z")

</div>

yes, I did, thank you both for your help.

---

<div class="post-metadata">

**Author:** ![EranML](https://avatars.discourse-cdn.com/v4/letter/e/c0e974/32.png) [@EranML](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FEranML)%5C
**Post date:** [April 28, 2023, 3:05pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftrainer-train-resume-from-checkpoint-true%2F13118%2F6 "2023-04-28T15:05:48Z")

</div>

If I don’t want to push my model to the hub?  
how can I resume the training from specific check point?

---

<div class="post-metadata">

**Author:** ![JaySyd](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@JaySyd](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJaySyd)%5C
**Post date:** [May 1, 2023, 1:59pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftrainer-train-resume-from-checkpoint-true%2F13118%2F7 "2023-05-01T13:59:23Z")

</div>

Hey Eran,

Had a similar question a while ago - all i did was specify the checkpoint path in the model and tokenizer declaration

e.g.

tokenizer = AutoTokenizer.from\_pretrained(“my\_awesome\_model/checkpoint-xxxx”)

model = AutoModelForSequenceClassification.from\_pretrained(“my\_awesome\_model/checkpoint-xxxx”)

and then leave trainer.train() without any arguments since you are loading the pretrained checkpoint already.

---

<div class="post-metadata">

**Author:** ![Cameron-oos](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/cameron-oos/32/23127_2.png) [@Cameron-oos](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FCameron-oos)%5C
**Post date:** [January 22, 2024, 7:28am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftrainer-train-resume-from-checkpoint-true%2F13118%2F8 "2024-01-22T07:28:05Z")

</div>

I came across this issue and I have a solution. I was using these for training\_args for a whisper model finetune for context

You can still use trainer.train() with no arguments and have it resume from checkpoint. You just include this in your training\_args:

training\_args = Seq2SeqTrainingArguments(  
output\_dir=“/your/path”, # change to a repo name of your choice  
resume\_from\_checkpoint=“/path/checkpoint-4000”,  
per\_device\_train\_batch\_size=16,  
gradient\_accumulation\_steps=1, # increase by 2x for every 2x decrease in batch size  
learning\_rate=1e-5,  
warmup\_steps=500,  
max\_steps=12000,  
gradient\_checkpointing=True,  
fp16=True, # Change to false if using CPU only  
evaluation\_strategy=“steps”,  
per\_device\_eval\_batch\_size=8,  
predict\_with\_generate=True,  
generation\_max\_length=225,  
save\_steps=1000,  
eval\_steps=1000,  
logging\_steps=25,  
report\_to=[“tensorboard”],  
load\_best\_model\_at\_end=True,  
metric\_for\_best\_model=“wer”,  
greater\_is\_better=False,  
push\_to\_hub=True,  
)

So resume\_from\_checkpoint does not want true/false in this case, it wants a “str” as a input argument. You’re IDE should show you when you hover you’re cursor over it, what the variable type the parameter requires.

Go to your local machine where you save your checkpoints and literally copy the directory to the checkpoint, for example here is a linux path to a checkpoint: resume\_from\_checkpoint = “/home/name/whispertuning/whisper-small-random/checkpoint-4000”.

![hfpic1](https://us1.discourse-cdn.com/hellohellohello/original/3X/8/1/819cf71fca5eebd0a97fef9a6fc1c0301e683bec.png)

I did not change any model or tokenizers (although you can do it that way and instead just use the checkpoint as your model but if you want to continuously train a model this will not be efficient.)

Just keep track of you’re metric. If you train it to 4000 steps, and you run another train, just have a look to see if your metrics are actually improving such as the word\_error\_rate for speech to text from the **previous checkpoint you were working from**. I hope this answers your question physically and conceptually.

---

<div class="post-metadata">

**Author:** ![aben118](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@aben118](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Faben118)%5C
**Post date:** [May 16, 2024, 3:48am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftrainer-train-resume-from-checkpoint-true%2F13118%2F9 "2024-05-16T03:48:23Z")

</div>

just want to understand it clearly – so when i resume from this checkpoint, it will not repeat the data it was already trained upon? (given the train and test set are the same size as before)

---

<div class="post-metadata">

**Author:** ![Cameron-oos](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/cameron-oos/32/23127_2.png) [@Cameron-oos](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FCameron-oos)%5C
**Post date:** [May 16, 2024, 10:05am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftrainer-train-resume-from-checkpoint-true%2F13118%2F10 "2024-05-16T10:05:28Z")

</div>

Correct. It will start training the model from the specified checkpoint and not regard the previous checkpoints.
