Rate this Page

torch.cuda.get_stream_from_external#

torch.cuda.get_stream_from_external(data_ptr, device=None)[source]#

Return a Stream from an externally allocated CUDA stream.

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

Note

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

Parameters
  • data_ptr (int) – Integer representation of the cudaStream_t value that is 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.

Return type

Stream