I guess it’s pytorch’s problem. The version I used is 0.4.0 at present. When I downgrade it to 0.3.0.post4, the training memory usage is about 7 GB, and the testing usage is about 2 GB. Anyone who knows the difference between these two versions?
I replace volatile=True with with torch.no_grad():, and loss.data[0] with loss.item(). But testing still costs similar memory.