torch.cpu¶ 此包实现了 torch.cuda 中的抽象,以便编写与设备无关的代码。 current_device 返回 CPU 的当前设备。 current_stream 返回给定设备的当前选定 Stream。 is_available 返回一个布尔值,指示 CPU 当前是否可用。 synchronize 等待 CPU 设备上所有流中的所有内核完成。 stream 围绕 Context-manager StreamContext 的包装器,用于选择给定流。 set_device 设置当前设备,在 CPU 中此操作无效。 device_count 返回 CPU 设备的数量(不是核心数)。 StreamContext Context-manager,用于选择给定流。 流和事件¶ Stream 注意