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.
- 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) – 要等待的事件。