DefaultCPUAllocator: can't allocate memory: you tried to allocate 100663296 bytes
Author: Abbyyan
Pull request: no

# ❓ 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 the Hugging Face forum: https://discuss.huggingface.co/ .
     You can also try Stack Overflow (SO) where a whole community of PyTorch and
     Tensorflow enthusiast can help you out. In this case, 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 
     -->

## Details
<!-- Description of your issue -->

I'm using the `run_language_modeling.py` to fine tuning the model `distilgpt2`. The command i used as follows:
```shell
python run_language_modeling.py --output_dir=output_dir --model_type gpt2 --model_name_or_path distilgpt2  --do_train  --train_data_file=data/data.txt  --overwrite_output_dir
```
But it core with following error
```shell
File "/data1/xxx/transformers/src/transformers/activations.py", line 30, in gelu_new
    return 0.5 * x * (1.0 + torch.tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * torch.pow(x, 3.0))))
RuntimeError: [enforce fail at CPUAllocator.cpp:64] . DefaultCPUAllocator: can't allocate memory: you tried to allocate 100663296 bytes. Error code 12 (Cannot allocate memory)
```
Does it core  duing to the insufficient memory on my machine? Hope for your help. Thanks a lot.

<!-- You should first ask your question on the forum or SO, and only if
     you didn't get an answer ask it here on GitHub. -->
**A link to original question on the forum/Stack Overflow**:

Comments:
This happens because you don't have sufficient memory in your machine, indeed. You can try reducing the batch size.

> This happens because you don't have sufficient memory in your machine, indeed. You can try reducing the batch size.

In my opinion, the problem occurs may due to my dataset is too large(Relative to the memory of my machine). But the loading data part may be optimized referring to the following issue. 
https://stackoverflow.com/questions/51444059/how-to-iterate-over-two-dataloaders-simultaneously-using-pytorch/57890309#57890309 

There are two questions:
(1) I've changed a machine to run the code. It started running normal,  but will quit midway while training. Is this also related to my machine's memory? 
This is the data of my machine during training.
![image](https://user-images.githubusercontent.com/12140508/92390398-5d669080-f14d-11ea-9260-55f6ead36c72.png)
This is the exit interface. I don't know what's the matter. 
![image](https://user-images.githubusercontent.com/12140508/92390715-fdbcb500-f14d-11ea-98f5-576d29eb9fb2.png)

(2) In addition , how can i use gpu to run `run_language_modeling.py` please. Thanks a lot.


I have a similar problem. Was there any solution in your case?


same problem

same problem

Were there any solutions to this? I am encountering the exact same issue trying to train Dolly on the original dataset.

same question when i train bloom

same issue, please let me know if any solution on this has been done


This is crazy! My model used to work fine. Now I am having the same issue. Not been able to solved it.

My model is quite simple:

    # Generate text
    outputs = model.generate(
        inputs.input_ids, 
        max_length=max_length, 
        num_return_sequences=1, 
        no_repeat_ngram_size=1, 
        early_stopping=True
    )


Any solutions?