It should work, if you push all the data in your Dataset onto the GPU, and use num_workers=0 as well as pin_memory=False in your DataLoader.
You could write your own Dataset of if you would like to use the torchvision.dataset.MNIST one, you could manipulate the underlying dataset.data and dataset.targets.