Unsure if you’ve solved this or not, but I ran into similar file i/o issues in Colab. The cleanest way I found for loading MNIST is to instead simply load it via keras, and then package it into a DataLoader. See the example here 2. (Caveat: Colab vomits when running the model, and as of this writing I still don’t know why).