Hello,
I am using huggingface
on my google colab pro+ instance, and I keep getting errors like
RuntimeError: CUDA out of memory. Tried to allocate 256.00 MiB (GPU 0; 15.78 GiB total capacity; 13.92 GiB already allocated; 206.75 MiB free; 13.94 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
I dont understand why? My dataset is microscopic (40K sentences), and all I am doing is loading bert-large-uncased
and follow along the text classification
notebook
from transformers import AutoTokenizer
from transformers import AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained('bert-large-cased')
from datasets import load_dataset, load_metric
metric = load_metric('glue', 'sst2')
model = AutoModelForSequenceClassification.from_pretrained("bert-large-cased", num_labels=2)
my trainer args are super standard
from transformers import AutoModelForSequenceClassification, TrainingArguments, Trainer
batch_size = 16
args = TrainingArguments(
evaluation_strategy = "epoch",
save_strategy = "epoch",
learning_rate=2e-5,
per_device_train_batch_size=batch_size,
per_device_eval_batch_size=batch_size,
num_train_epochs=5,
report_to="none",
weight_decay=0.01,
output_dir='/content/drive/MyDrive/kaggle/',
metric_for_best_model='accuracy')
def compute_metrics(eval_pred):
predictions, labels = eval_pred
predictions = predictions[:, 0]
return metric.compute(predictions=predictions, references=labels)
trainer = Trainer(
model,
args,
train_dataset=tokenized_datasets['train'],
eval_dataset=tokenized_datasets['test'],
tokenizer=tokenizer,
compute_metrics=compute_metrics
)
Am I missing something? Should I change some of the options?
Thanks!!