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 also set the environment variable to
CUDA_VISIBLE_DEVICES=""
without having to modify the source code.
If the above answers don't work, try:
os.environ['CUDA_VISIBLE_DEVICES'] = '-1'
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