It is tricky because CUDA does not allow you to easily share data across processes. And so the transfert from the process that loads the sample to the main one won’t be optimal.
You want to get a Tensor from pinned memory and send it to the GPU in the main process to avoid such issues.