tensorflow - 在 GPU 上训练的模型可以在 CPU 上用于推理,反之亦然吗?

标签 tensorflow

我想知道在 GPU 上训练的模型是否可以用于使用 CPU 运行推理? (反之亦然) 谢谢你!

最佳答案

只要您的模型没有显式设备分配,您就可以执行此操作。 IE,如果您的模型具有像 with tf.device('gpu:0') 这样的 block ,那么当您在没有 GPU 的模型上运行它时,它会提示。

在这种情况下,您必须确保导入的模型没有显式设备分配,例如,但在 import_meta_graph 中使用 clear_devices 参数

关于tensorflow - 在 GPU 上训练的模型可以在 CPU 上用于推理,反之亦然吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40980035/

相关文章:

python - Keras神经网络: ValueError - input shape is wrong

python - Tensorflow:高效地将数据移动/放入 GPU

tensorflow - 张量板标量看起来一团糟

python - 如果 LSTM 单元由同一个函数创建,它们会共享权重吗?

python - 为什么在 tensorflow 中同时存在 tf.round 和 tf.rint 函数?

python - 加载 keras 模型时出现 ValueError : ('Unrecognized keyword arguments:' , dict_keys( ['ragged' ]))

tensorflow - 训练损失随着数据大小的增加而增加,训练精度几乎保持不变

tensorflow - 在 TensorFlow 教程中下载 Fashion MNIST 文件需要很长时间

python - 如何从keras模型中获取权重?

python - 类型错误 : Could not build a TypeSpec with type KerasTensor