打印GPU的总内存和可用内存:print('Total memory:', torch.cuda.get_device_properties(i).total_memory, 'Available memory:', torch.cuda.get_device_properties(i).total_memory - torch.cuda.memory_allocated(i)) 打印模型在GPU上的内存占用:model = ... # your model here print('Model memory on GPU...