torch_npu.npu.SyncLaunchStream(device)
创建一条同步下发NPUStream,在该流上下发的任务不再使用taskqueue异步下发。在集群场景其中某一设备出现故障,其他设备保存checkpoint时,可使用此同步下发流保存。
“device”(Any) – 可以为设备数字id或者字符串“npu:0”,默认值为“none”(即当前线程对应的设备id)。
一条创建好的NPUStream,在该流上下发任务不再使用taskqueue异步下发。
1 2 3 4 5 | s = torch.npu.SyncLaunchStream() with torch.npu.stream(s): tensor1 =torch.randn(4).npu() tensor2 = tensor1 + tensor1 s.synchronize() |