当你安装上gpu版本的tensorflow2时,默认情况下使用GPU,当你想要切换回CPU运行程序时,
你需要的代码开头添加一句代码
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"