在 gpu 上训练的模型可以在 cpu 上用于推理,反之亦然? [英] Can a model trained on gpu used on cpu for inference and vice versa?

查看:162
本文介绍了在 gpu 上训练的模型可以在 cpu 上用于推理,反之亦然?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I was wondering if a model trained on the GPU could be use to run inference with the cpu ? (And vice versa) Thanks to you!

推荐答案

只要您的模型没有明确的设备分配,您就可以这样做.IE,如果你的模型有像 with tf.device('gpu:0') 这样的块,当你在没有 GPU 的模型上运行它时它会抱怨.

You can do it as long as your model doesn't have explicit device allocations. IE, if your model has blocks like with tf.device('gpu:0'), it'll complain when you run it on model without GPU.

在这种情况下,您必须确保导入的模型没有明确的设备分配,例如,但在 import_meta_graph

In such cases you must make sure your imported model doesn't have explicit device assignments, for instance, but using clear_devices argument in import_meta_graph

这篇关于在 gpu 上训练的模型可以在 cpu 上用于推理,反之亦然?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆