如何在 CPU 上运行 Tensorflow [英] How to run Tensorflow on CPU
本文介绍了如何在 CPU 上运行 Tensorflow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在 Ubuntu 14.04 上安装了 GPU 版本的 tensorflow.
I have installed the GPU version of tensorflow on an Ubuntu 14.04.
我在 GPU 服务器上,tensorflow 可以在其中访问可用的 GPU.
I am on a GPU server where tensorflow can access the available GPUs.
我想在 CPU 上运行 tensorflow.
I want to run tensorflow on the CPUs.
通常我可以使用 env CUDA_VISIBLE_DEVICES=0
在 GPU 上运行.0.
Normally I can use env CUDA_VISIBLE_DEVICES=0
to run on GPU no. 0.
我该如何在 CPU 之间进行选择?
How can I pick between the CPUs instead?
我不感兴趣用 with tf.device("/cpu:0") 重写我的代码:
推荐答案
您可以为每个 tf.Session
应用 device_count
参数:
You can apply device_count
parameter per tf.Session
:
config = tf.ConfigProto(
device_count = {'GPU': 0}
)
sess = tf.Session(config=config)
另见protobuf配置文件:
See also protobuf config file:
tensorflow/core/framework/config.proto
这篇关于如何在 CPU 上运行 Tensorflow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文