评价此页

torch.cuda.memory_usage#

torch.cuda.memory_usage(device=None)[source]#

返回在过去采样周期内,根据 nvidia-smi 显示的全局(设备)内存读写时间百分比。

参数

device (torch.deviceint, optional) – 选定的设备。如果 deviceNone(默认),则返回当前设备(由 current_device() 指定)的统计信息。

返回类型

int

警告:每个采样周期可能在 1 秒到 1/6 秒之间,具体取决于查询的产品。