I was using TF version 2.5 and have just upgraded to 2.6 where I am still getting the same issue. I am also using Python 3.6.
After I upgraded to TF 2.6, I am still getting the error, but the path is different.
In 2.6:
“W tensorflow/core/data/root_dataset.cc:167] Optimization loop failed: Cancelled: Operation was cancelled”
Whereas in 2.5:
“W tensorflow/core/kernels/data/model_dataset_op.cc:205] Optimization loop failed: Cancelled: Operation was cancelled”

I looked through that tread, but I wasn’t able to solve the problem. The error is that tread also has a different path:
“W tensorflow/core/kernels/data/generator_dataset_op.cc:103] Error occurred when finalizing GeneratorDataset iterator: Cancelled: Operation was cancelled”
Any help would be appreciated.