Using GPU in dataloader with num_workers>0

I want to achieve the following in the dataloader (in the getitem method):
Converting loaded data to a tensor on the GPU, and using the GPU to perform some processing on the tensor. When I set num_workers>0, I get the following error:
RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the ‘spawn’ start method

I am wondering if there is an established method to perform GPU processing in the dataloader with num_workers>0

Have you tried using the mentioned 'spawn' method and if so what kind of error are you seeing?

No I have not tried using the ‘spawn’ method. I will try that and update you if I have a problem.