Thanks for the quick reply. I tried it now but unfortunately the problem persists when using torch.no_grad(). Wrapping the model call in no_grad() only works when I set the number of workers in the dataloader to 0. If the number of workers is greater than 0 the process hangs again.