from os import environ
environ['CUDA_VISIBLE_DEVICES'] = '-1'
with tf.device('/cpu:0'): #cpu를 사용한다.
"/cpu:0"
: The CPU of your machine."/device:GPU:0"
: The GPU of your machine, if you have one."/device:GPU:1"
: The second GPU of your machine, etc.