# Bug in the train-with-pytorch-trainer?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fbug-in-the-train-with-pytorch-trainer%2F53182%3E%5C
**Category:** Beginners\
**Created:** [September 1, 2023, 5:48pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fbug-in-the-train-with-pytorch-trainer%2F53182 "2023-09-01T17:48:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![huggingEars](https://avatars.discourse-cdn.com/v4/letter/h/5e9695/32.png) [@huggingEars](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FhuggingEars)%5C
**Post date:** [September 1, 2023, 5:48pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fbug-in-the-train-with-pytorch-trainer%2F53182%2F1 "2023-09-01T17:48:34Z")

</div>

There may be a bug in [Fine-tune a pretrained model](https://huggingface.co/docs/transformers/v4.32.1/training#train-with-pytorch-trainer)

From that link I select, “Open in Colab”. The I selected from the menu, “Runtime-\>Run All”. Everything appears to work file until I get to the section:

from transformers import TrainingArguments

training\_args = TrainingArguments(output\_dir=“test\_trainer”)

I get the following output:  
/usr/local/lib/python3.10/dist-packages/IPython/core/interactiveshell.py:3553 in run\_code │  
│ │  
│ 3550 │ │ │ │ elif async\_ : │  
│ 3551 │ │ │ │ │ await eval(code\_obj, self.user\_global\_ns, self.user\_ns) │  
│ 3552 │ │ │ │ else: │  
│ ❱ 3553 │ │ │ │ │ exec(code\_obj, self.user\_global\_ns, self.user\_ns) │  
│ 3554 │ │ │ finally: │  
│ 3555 │ │ │ │ # Reset our crash handler in place │  
│ 3556 │ │ │ │ sys.excepthook = old\_excepthook │  
│ in \<cell line: 3\>:3 │  
│ in **init** :114 │  
│ │  
│ /usr/local/lib/python3.10/dist-packages/transformers/training\_args.py:1400 in **post\_init** │  
│ │  
│ 1397 │ │ if ( │  
│ 1398 │ │ │ self.framework == “pt” │  
│ 1399 │ │ │ and is\_torch\_available() │  
│ ❱ 1400 │ │ │ and (self.device.type != “cuda”) │  
│ 1401 │ │ │ and (self.device.type != “npu”) │  
│ 1402 │ │ │ and (get\_xla\_device\_type(self.device) != “GPU”) │  
│ 1403 │ │ │ and (self.fp16 or self.fp16\_full\_eval) │  
│ │  
│ /usr/local/lib/python3.10/dist-packages/transformers/training\_args.py:1857 in device │  
│ │  
│ 1854 │ │ The device used by this process. │  
│ 1855 │ │ “”" │  
│ 1856 │ │ requires\_backends(self, [“torch”]) │  
│ ❱ 1857 │ │ return self.\_setup\_devices │  
│ 1858 │ │  
│ 1859 │ @property │  
│ 1860 │ def n\_gpu(self): │  
│ │  
│ /usr/local/lib/python3.10/dist-packages/transformers/utils/generic.py:54 in **get** │  
│ │  
│ 51 │ │ attr = “\__cached_” + self.fget. **name** │  
│ 52 │ │ cached = getattr(obj, attr, None) │  
│ 53 │ │ if cached is None: │  
│ ❱ 54 │ │ │ cached = self.fget(obj) │  
│ 55 │ │ │ setattr(obj, attr, cached) │  
│ 56 │ │ return cached │  
│ 57 │  
│ │  
│ /usr/local/lib/python3.10/dist-packages/transformers/training\_args.py:1772 in \_setup\_devices │  
│ │  
│ 1769 │ │ logger.info(“PyTorch: setting up devices”) │  
│ 1770 │ │ if not is\_sagemaker\_mp\_enabled(): │  
│ 1771 │ │ │ if not is\_accelerate\_available(min\_version=“0.20.1”): │  
│ ❱ 1772 │ │ │ │ raise ImportError( │  
│ 1773 │ │ │ │ │ "Using the `Trainer` with `PyTorch` requires `accelerate>=0.20.1`: P │  
│ 1774 │ │ │ │ ) │  
│ 1775 │ │ │ AcceleratorState.\_reset\_state(reset\_partial\_state=True) │  
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯  
ImportError: Using the `Trainer` with `PyTorch` requires `accelerate>=0.20.1`: Please run `pip install transformers[torch]` or `pip install accelerate -U`

Nothing runs after that. Is it user error or is there a problem?

Thanks

---

<div class="post-metadata">

**Author:** ![muellerzr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/muellerzr/32/21583_2.png) [@muellerzr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmuellerzr)%5C
**Post date:** [September 1, 2023, 5:50pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fbug-in-the-train-with-pytorch-trainer%2F53182%2F2 "2023-09-01T17:50:41Z")

</div>

> [@huggingEars](#):
>
> Nothing runs after that. Is it user error or is there a problem?

I’d recommend doing a quick search on the forums, this is a very popular question. `pip install accelerate -U` and restart your runtime

---

<div class="post-metadata">

**Author:** ![huggingEars](https://avatars.discourse-cdn.com/v4/letter/h/5e9695/32.png) [@huggingEars](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FhuggingEars)%5C
**Post date:** [September 1, 2023, 7:12pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fbug-in-the-train-with-pytorch-trainer%2F53182%2F3 "2023-09-01T19:12:10Z")

</div>

Thank you @muellerzr for the quick and accurate response. Sorry for the duplicate question, I had searched but was clearly using the wrong search terms. I also noted that ‘evaluate’ had to be pip installed as well. As a suggestion to huggingface team, maybe the model code could be updated or at least the text surrounding the accelerate and evaluate issues.
