我想在CPU上运行推理;尽管我的机器有GPU。我想知道是否有可能强制TensorFlow使用中央处理器而不是图形处理器?
默认情况下,TensorFlow会自动使用GPU进行推理,但由于我的GPU不好(OOM‘’ed),我想知道是否有设置强制Tensorflow使用CPU进行推理?
为了进行推断,我使用:
tf.contrib.predictor.from_saved_model("PATH")发布于 2020-07-11 14:03:20
假设您使用的是TensorFlow 2.0,请在GitHub上查看此问题:
解决方案似乎是对TensorFlow隐藏图形处理器设备。您可以使用下面描述的方法之一来完成此操作:
TensorFlow 2.0:
my_devices = tf.config.experimental.list_physical_devices(device_type='CPU')
tf.config.experimental.set_visible_devices(devices= my_devices, device_type='CPU')TensorFlow 2.1:
tf.config.set_visible_devices([], 'GPU')(感谢@ymodak和@henrysky,他们回答了关于GitHub问题的问题。)
https://stackoverflow.com/questions/62843629
复制相似问题