Global configuration
running TensorFlow codes when OOM (Out of Memory) errors often occur because batch_size set too high resulting in insufficient memory. If you want only the code running in CPU, may be added to the original code in the following code:
import os
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"