评价此页

ExternalStream#

class torch.cuda.ExternalStream(stream_ptr, device=None, **kwargs)[source]#

Wrapper around an externally allocated CUDA stream.

This class is used to wrap streams allocated in other libraries in order to facilitate data exchange and multi-library interactions.

注意

This class doesn’t manage the stream life-cycle, it is the user responsibility to keep the referenced stream alive while this class is being used.

参数
  • stream_ptr (int) – Integer representation of the cudaStream_t value. allocated externally.

  • device (torch.device or int, optional) – the device where the stream was originally allocated. If device is specified incorrectly, subsequent launches using this stream may fail.

query()[source]#

检查所有提交的工作是否已完成。

返回

一个布尔值,指示此流中的所有内核是否已完成。

返回类型

布尔值

record_event(event=None)[source]#

Record an event.

参数

event (torch.cuda.Event, optional) – event to record. If not given, a new one will be allocated.

返回

记录的事件。

synchronize()[source]#

等待此流中的所有内核完成。

注意

This is a wrapper around cudaStreamSynchronize(): see CUDA Stream documentation for more info.

wait_event(event)[源代码]#

使提交到此流的所有未来工作等待一个事件。

参数

event (torch.cuda.Event) – 要等待的事件。

注意

这是 cudaStreamWaitEvent() 的包装器:有关更多信息,请参阅 CUDA Stream 文档

此函数在不等待 event 的情况下返回:仅影响未来的操作。

wait_stream(stream)[源代码]#

与另一个流同步。

提交到此流的所有未来工作将等待,直到调用时提交到给定流的所有内核完成。

参数

stream (Stream) – 要同步的流。

注意

此函数在不等待 stream 中当前排队的内核的情况下返回:仅影响未来的操作。