I’m getting this same error.
2021-12-13 17:59:55.175834: W tensorflow/core/data/root_dataset.cc:163] Optimization loop failed: CANCELLED: Operation was cancelled

I know that my problem isn’t the batch size being larger than my dataset. I checked the size of the dataset each time I got the error, and it’s the same size as when I don’t get the error. Speaking of which, I don’t get this error every time I run the code. It seems almost random, but it obviously can’t be.
I can’t find a solution to this anywhere, so I’m hoping someone here can help me out.