check if works with num_worker=0 if you are using windows.
It worked for me. here is reference

  
      

      PyTorch Forums – 2 May 19
  

  
    

Cannot enumerate over Dataloader object

  Is your code running fine using num_workers=0?  If you are using multiple workers on Windows, you should add the if-clause protection as described in the Windows FAQ.