pin_memory=True and num_worker >1 . Occur CUDA Driver Error

  1. use torch.spawn
  2. dataloader: pin_memory=True.
  3. dataloader: num_worker>1.
    ERROR: RuntimeError: CUDA driver error: initialization error

I guess you are trying to re-initialize the CUDA context in each new process, which will fail.