torch.cuda.memory_usage#
- torch.cuda.memory_usage(device=None)[source]#
返回在过去采样周期内,根据 nvidia-smi 显示的全局(设备)内存读写时间百分比。
- 参数
device (torch.device 或 int, optional) – 选定的设备。如果
device
为None
(默认),则返回当前设备(由current_device()
指定)的统计信息。- 返回类型
警告:每个采样周期可能在 1 秒到 1/6 秒之间,具体取决于查询的产品。