Shortcuts

torch.cuda.get_stream_from_external

torch.cuda.get_stream_from_external(data_ptr, device=None)[source][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

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources