Gradient overflow issue when i try to train gpt2 with run_language_modeling in fp16 with 02. Any idea why that maybe happen?
# ❓ Questions & Help

<!-- The GitHub issue tracker is primarly intended for bugs, feature requests,
     new models and benchmarks, and migration questions. For all other questions,
     we direct you to Stack Overflow (SO) where a whole community of PyTorch and
     Tensorflow enthusiast can help you out. Make sure to tag your question with the
     right deep learning framework as well as the huggingface-transformers tag: 
     https://stackoverflow.com/questions/tagged/huggingface-transformers 
     
     If your question wasn't answered after a period of time on Stack Overflow, you
     can always open a question on GitHub. You should then link to the SO question 
     that you posted.
     -->

## Details
<!-- Description of your issue -->

<!-- You should first ask your question on SO, and only if
     you didn't get an answer ask it here on GitHub. -->
**A link to original question on Stack Overflow**:

![Screenshot from 2020-05-31 13-49-05](https://user-images.githubusercontent.com/35643708/83350909-172cb480-a348-11ea-97a5-d8745626e774.png)
I get this message every 2000 steps. 
"Gradient overflow.  Skipping step, loss scaler 0 reducing loss scale to 262144.0"

The train run on rtx 2070 and seems to not have other problem but that message keeps going on every 2000 steps.

pytorch 1.5.0
python 3.7
cuda 10.1
<|||||>Do you have the same issue with opt level O1? Using O2 is discouraged. The issue may also be related to PyTorch 1.5, so if switching to O1 does not help, try a previous PyTorch version. Note that it is highly likely that this is an AMP problem, not a transformers issue. Have a look here https://github.com/NVIDIA/apex/issues/318<|||||>@BramVanroy  Yes i guess you 're right. It seems problem of the AMP. I asked and in APEX the same question and their answer was : 

"The loss scaler tries to increase the loss scaling factor after a threshold of successful steps was reached. In your case it seems that the scaling factor is being downgraded to the same value, so it should be fine."

So, according to that answer, is not a problem. But still i am not sure. 

<|||||>I guess that skipping one step every 2000 steps is not a problem. You can monitor the loss, and as long as it seems to decrease normally, then you should be fine. <|||||>This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
