Solved by jcbrouwer in post #4 
              
              
                Ok, then I think you want to write a custom Dataset class and then use a Dataloader with num_workers=0. 
That way the dataloader shouldn’t do any multiprocessing and so you can use your GPU to preprocess in the Dataset class.