Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"):

like image 719
Alexander R Johansen Avatar asked Oct 15 '22 19:10

Alexander R Johansen


People also ask

Can you run TensorFlow on CPU?

TensorFlow supports running computations on a variety of types of devices, including CPU and GPU.

Can you use TensorFlow without GPU?

The main difference between this, and what we did in Lesson 1, is that you need the GPU enabled version of TensorFlow for your system. However, before you install TensorFlow into this environment, you need to setup your computer to be GPU enabled with CUDA and CuDNN.


2 Answers

You can also set the environment variable to

CUDA_VISIBLE_DEVICES=""

without having to modify the source code.

like image 203
fabrizioM Avatar answered Oct 17 '22 07:10

fabrizioM


If the above answers don't work, try:

os.environ['CUDA_VISIBLE_DEVICES'] = '-1'
like image 150
Aravindh Kuppusamy Avatar answered Oct 17 '22 08:10

Aravindh Kuppusamy