Rate this Page

torch.cuda.get_stream_from_external#

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

Return aStream from an externally allocated CUDA stream.

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

Note

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

Parameters
  • data_ptr (int) – Integer representation of thecudaStream_t value thatis allocated externally.

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

Return type

Stream