import os os.environ["CUDA_VISIBLE_DEVICES"]="-1" import tensorflow as tf
参考: https://stackoverflow.com/questions/44552585/prevent-tensorflow-from-accessing-the-gpu