How to solve this question "RuntimeError: CUDA out of memory."?
I'm going to extract a feature from pictures.I first define a tensor data_feature_map, and then use torch.cat to stack the features of one picture. 

My code is :

data_feature_map = torch.ones(1,2048)
for i, data in enumerate(train_loader, 0):
    img, _ = data
    img.requires_grad_=False
    if torch.cuda.is_available():
        img = img.cuda()
    out = model(img)
    # out.shape = [1,2048]
    out = out.view(1,-1).cpu()
    data_feature_map = torch.cat((data_feature_map, out), 0)


but when i run it, it will show the error "RuntimeError: CUDA out of memory."

please tell me why this error occurs.Thank you very much. 

Since your GPU is running out of memory, you can try few things:

1.) Reduce your batch size

2.) Reduce your network size
