# Can't use Trainer( ) in Colab

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-use-trainer-in-colab%2F50370%3E%5C
**Category:** Beginners\
**Created:** [August 11, 2023, 5:58am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-use-trainer-in-colab%2F50370 "2023-08-11T05:58:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zobaid1933](https://avatars.discourse-cdn.com/v4/letter/z/f05b48/32.png) [@zobaid1933](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fzobaid1933)%5C
**Post date:** [August 11, 2023, 5:58am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-use-trainer-in-colab%2F50370%2F1 "2023-08-11T05:58:30Z")

</div>

trainer = Trainer()

> [@zobaid1933](#):
>
> * * *
> 
> ImportError Traceback (most recent call last)  
> in \<cell line: 1\>()  
> ----\> 1’‘’ trainer = Trainer()‘’’
> 
> 5 frames  
> /usr/local/lib/python3.10/dist-packages/transformers/training\_args.py in \_setup\_devices(self)  
> 1714 if not is\_sagemaker\_mp\_enabled():  
> 1715 if not is\_accelerate\_available(min\_version=“0.20.1”):  
> → 1716 raise ImportError(  
> 1717 “Using the `Trainer` with `PyTorch` requires `accelerate>=0.20.1`: Please run `pip install transformers[torch]` or `pip install accelerate -U`”  
> 1718 )
> 
> ImportError: Using the `Trainer` with `PyTorch` requires `accelerate>=0.20.1`: Please run `pip install transformers[torch]` or `pip install accelerate -U`
> 
> * * *
> 
> NOTE: If your import is failing due to a missing package, you can  
> manually install dependencies using either !pip or !apt.

ImportError Traceback (most recent call last)  
 in \<cell line: 1\>()

5 frames  
/usr/local/lib/python3.10/dist-packages/transformers/training\_args.py in \_setup\_devices(self)  
1714 if not is\_sagemaker\_mp\_enabled():  
1715 if not is\_accelerate\_available(min\_version=“0.20.1”):  
 → 1716 raise ImportError(  
1717 “Using the `Trainer` with `PyTorch` requires `accelerate>=0.20.1`: Please run `pip install transformers[torch]` or `pip install accelerate -U`”  
1718 )

ImportError: Using the `Trainer` with `PyTorch` requires `accelerate>=0.20.1`: Please run `pip install transformers[torch]` or `pip install accelerate -U`

* * *

NOTE: If your import is failing due to a missing package, you can  
manually install dependencies using either !pip or !apt.

---

<div class="post-metadata">

**Author:** ![mariosasko](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mariosasko/32/31548_2.png) [@mariosasko](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmariosasko)%5C
**Post date:** [August 16, 2023, 12:25pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-use-trainer-in-colab%2F50370%2F2 "2023-08-16T12:25:02Z")

</div>

Hi! As per the error message, you need to update the `accelerate` package with `!pip install accelerate -U` and then restart the runtime by clicking `Runtime` → `Restart runtime` for the update to take effect.
