Hi, ptrblck! Thank you for the reply.
First, to answer your question, the original images were resized to 152 * 242 pix, and I used batch_size = 1, but still got memory shortage problem before the first epoch finishes.
Here is a good news (well good for me). I solved the problem by substitute all layers from ResNet34 to other variables instead of using hook. I thought the cause was that the list in which intermediate outputs were stored, self.skips in class seg_resnet34 never got refreshed. (Also, if self.skips remains un-refreshed, the rest of my code won’t work because it cant’t acquire appropriate intermediate outputs.)
Again, thank you for your help.