I think it's a pretty common message for PyTorch users with low GPU memory:
RuntimeError: CUDA out of memory. Tried to allocate ?? MiB (GPU ??; ?? GiB total capacity; ?? GiB already allocated; ?? MiB free; ?? cached)
I want to research object detection algorithms for my coursework. And many deep learning architectures require a large capacity of GPU-memory, so my machine can't train those models. I tried to process an image by loading each layer to GPU and then loading it back:
for m in self.children():
m.cuda()
X = m(X)
m.cpu()
torch.cuda.empty_cache()
But it doesn't seem to be very effective. I'm wondering is there any tips and tricks to train large deep learning models while using little GPU memory. Thanks in advance!
Edit: I'm a beginner in deep learning. Apologize if it's a dummy question:)
question from:https://stackoverflow.com/questions/59129812/how-to-avoid-cuda-out-of-memory-in-pytorch