How to run Tensorflow on CPU

I have installed the GPU version of tensorflow on an Ubuntu 14.04.

I am on a GPU server where tensorflow can access the available GPUs.

I want to run tensorflow on the CPUs.

Normally I can use env CUDA_VISIBLE_DEVICES=0 to run on GPU no. 0.

How can I pick between the CPUs instead?

I am not intersted in rewritting my code with with tf.device("/cpu:0"):

You can apply device_count parameter per tf.Session:

    config = tf.ConfigProto(
            device_count = {'GPU': 0}
        )
    sess = tf.Session(config=config)

See also protobuf config file:

tensorflow/core/framework/config.proto

From: stackoverflow.com/q/37660312

Back to homepage or read more recommendations: