AttributeError: 'DataLoader' object has no attribute 'pin_memory_device'

This PR added the pin_memory_device attribute to the DataLoader in April 2022, so your PyTorch release should already contain it since 1.12.1 was released in August 2022.
Could you double check if you are indeed using this version as I can access this attribute in 1.12.1:

>>> torch.__version__
'1.12.1+cu116'
>>> loader = torch.utils.data.DataLoader(torch.randn(1, 1), pin_memory=True, pin_memory_device="cuda")
>>> loader.pin_memory_device
'cuda'
1 Like