服务器的gpu内存不够,导致程序运行失败。 问题如下: RuntimeError: CUDA out of memory. Tried to allocate 38.15 GiB (GPU 0; 31.75 GiB total capacity; 1.07 GiB already allocated; 26.18 GiB free; 3.45 GiB cached) 内存不够的解决办法: 1.不使用梯度方法 在test过程中,在dataloader循环前加入, with torch