'google colab memory issues

I am trying to run the code from this page using google colab and provided GPU. I get the below error. Is there any efficient way to run that code

trainer.train()

The following columns in the training set  don't have a corresponding argument in `LongformerForSequenceClassification.forward` and have been ignored: text.
/usr/local/lib/python3.7/dist-packages/transformers/optimization.py:309: FutureWarning: This implementation of AdamW is deprecated and will be removed in a future version. Use thePyTorch implementation torch.optim.AdamW instead, or set `no_deprecation_warning=True` to disable this warning
  FutureWarning,
***** Running training *****
  Num examples = 25000
  Num Epochs = 1
  Instantaneous batch size per device = 8
  Total train batch size (w. parallel, distributed & accumulation) = 64
  Gradient Accumulation steps = 8
  Total optimization steps = 390
Initializing global attention on CLS token...

---------------------------------------------------------------------------

RuntimeError                              Traceback (most recent call last)

<ipython-input-28-3435b262f1ae> in <module>()
----> 1 trainer.train()

15 frames

/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py in softmax(input, dim, _stacklevel, dtype)
   1680         ret = input.softmax(dim)
   1681     else:
-> 1682         ret = input.softmax(dim, dtype=dtype)
   1683     return ret
   1684 

RuntimeError: CUDA out of memory. Tried to allocate 194.00 MiB (GPU 0; 11.17 GiB total capacity; 10.13 GiB already allocated; 161.81 MiB free; 10.42 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source