在Ubuntu系統上使用PyTorch時,可通過以下方式優化內存:
torch.cuda.amp
torch.cuda.empty_cache()
del
gc.collect()
num_workers
torch.cuda.memory_summary()