# Error using Trainer with Colab notebook, anyone have a solution?

**URL:** <https://discuss.huggingface.co/t/error-using-trainer-with-colab-notebook-anyone-have-a-solution/157189>\
**Category:** 🤗Transformers\
**Created:** [May 29, 2025, 1:32am UTC](https://discuss.huggingface.co/t/error-using-trainer-with-colab-notebook-anyone-have-a-solution/157189 "2025-05-29T01:32:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbrown1981](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@dbrown1981](https://discuss.huggingface.co/u/dbrown1981)\
**Post date:** [May 29, 2025, 1:32am UTC](https://discuss.huggingface.co/t/error-using-trainer-with-colab-notebook-anyone-have-a-solution/157189/1 "2025-05-29T01:32:20Z")

</div>

from transformers import (  
DistilBertTokenizer,  
DistilBertForSequenceClassification,  
Trainer,  
TrainingArguments,  
)  
from transformers.trainer import Trainer  
trainer = Trainer(  
model=model,  
args=training\_args,  
train\_dataset=train\_dataset,  
eval\_dataset=test\_dataset,  
compute\_metrics=compute\_metrics  
)  
trainer.train()  
Got this error: ValueError Traceback (most recent call last)  
 in \<cell line: 0\>()  
1 # 7. Fine-tune the model  
----\> 2 trainer.train()

15 frames  
/usr/local/lib/python3.11/dist-packages/datasets/formatting/formatting.py in \_arrow\_array\_to\_numpy(self, pa\_array)  
194 ):  
195 return np.array(array, copy=False, dtype=object)  
 → 196 return np.array(array, copy=False)  
197  
198

ValueError: Unable to avoid copy while creating an array as requested.  
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [May 29, 2025, 4:39am UTC](https://discuss.huggingface.co/t/error-using-trainer-with-colab-notebook-anyone-have-a-solution/157189/2 "2025-05-29T04:39:45Z")

</div>

Perhaps `numpy>=2` issue…?

> [@ValueError: Unable to avoid copy while creating an array as requested](https://discuss.huggingface.co/t/valueerror-unable-to-avoid-copy-while-creating-an-array-as-requested/93584):
>
> I am doing the NLP course in Hugging Faces. In chapter 3 - Fine-tuning a pretrained model, subchapter 3 - Fine-tuning a model with the Trainer API, Under the “Evaluation” section, I’m trying to run the following code as specified in the course: import evaluate metric = evaluate.load("glue", "mrpc") metric.compute(predictions=preds, references=predictions.label\_ids) But when I run it, I’m getting the following ValueError ---------------------------------------------------------------------…

in Colab:

```auto
!pip install numpy==1.26.4

```
