I’m using this documentation guide to share a CUDA tensor between 2 python mp processes using share_memory_() and a torch.mp.Queue.
The tensors in the source arrive from an external source in streams as CUDA buffers, so I don’t have full control apart from converting them to a Tensor allocated on CUDA device (if you want details I can provide them in a reply).
I wanted to pass some metadata along with the CUDA tensor e.g. a string name/key for each image in the batch tensor (i.e. the first dimension indices of the tensor).
I was wondering if the same shared memory (zero copy) between processes can work when:
- Wrapping the CUDA tensor to be shared in a python class with these metadata as additional attributes.
- Somehow attaching metadata within the tensor itself. I saw this topic discussion but it seems non-standard and non-trivial at least.
Is there a way to send metadata along with each tensor in any way?
Thank you very much for all your help!