I found it easier to not use Dataset and Dataloader at all and rely on async. Here’s a writeup (with code): https://medium.com/@jonathan.wickens/using-postgres-as-a-dataloader-with-pytorch-bba0d5cbe1fa 187