在Ubuntu系统上使用PyTorch时,可通过以下方式优化内存:
torch.cuda.amp
torch.cuda.empty_cache()
del
gc.collect()
num_workers
torch.cuda.memory_summary()