Tensorflow 2.0 / Keras designated CPU operation, CPU enforce

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"
Published 236 original articles · won praise 157 · views 560 000 +

Guess you like

Origin blog.csdn.net/MrCharles/article/details/103708297