'Trainer' object has no attribute 'do_grad_scaling'

On colab, error with ‘Trainer’ object has no attribute ‘do_grad_scaling’. Why no such error on official jupyter lab server?

1 Like

Hi @SBFALLOUT,

This can be because one of the packages used for this notebook has a different version on the platform and, possibly the latest, version on in the colab environment. The author might have moved around the things a little bit which is why you are getting this error.

In order to avoid such inconveniences in running things in a colab or locally, please make sure you are using exact package versions as they are being used in the platform.

Best,
Mubsi

1 Like

I have the same problem despite working on jupyter notebook.In the utilities.py file there is no “do_grad_scaling” attribute. how can I get the latest version of file?

Thanks,
Volkan

1 Like

Hi @Volkan_Celik,

Please take note of this comment.

How does one find the package versions ?

!pip list doesn’t work

Try !pip install transformers==4.32.1
This works for me, I hope this will work for you as well.

3 Likes

Thank you!It works for me too

The stack trace indicates that the error is in utilities.py file, near line 276

I have replaced this

      if self.do_grad_scaling:
          self.scaler.scale(loss).backward()
      else:
          self.accelerator.backward(loss)

with this

      #if self.do_grad_scaling:
      #    self.scaler.scale(loss).backward()
      #else:
      self.accelerator.backward(loss)