Google Colab crashing again and again

I am trying to extract features.

extracted_features = []
main_extracted_features = []
for batch in range(100):
print(“Batch Number”,batch)
data_for = new_data[batch*100:(batch+1)*100]
for i in range(len(data_for)):
img = torch.tensor(data_for[i]/255).float()
ft_extract = feature_extractor(img.to(device))
extracted_features.append(ft_extract)
main_extracted_features.append(extracted_features)
print(np.array(extracted_features).shape)
print(np.array(main_extracted_features).shape)

and then crashes

It would seem like colab is running out of memory. I think it is because of not using .detach() function but not sure, have to look at more of the code.

Did it say because Colab is out of RAM? I have had Colab crashing from last night for “unknown reason”. What is your runtime log output? For me, it’s always crashes after “zmq.error.ZMQError: Address already in use”.