Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

By default, does TensorFlow use GPU/CPU simultaneously for computing or GPU only?

By default, TensorFlow will use our available GPU devices. That said, does TensorFlow use GPUs and CPUs simultaneously for computing, or GPUs for computing and CPUs for job handling (no matter how, CPUs are always active, as I think)?

like image 811
Raymond Lucky Avatar asked Sep 06 '25 03:09

Raymond Lucky


2 Answers

Generally it uses both, the CPU and the GPU (assuming you are using a GPU-enabled TensorFlow). What actually gets used depends on the actual operations that your code is using.

For each operation available in TensorFlow, there are several "implementations" of such operation, generally a CPU implementation and a GPU one. Some operations only have CPU implementations as it makes no sense for a GPU implementation, but overall most operations are available for both devices.

If you make custom operations then you need to provide implementations that you want.

like image 142
Dr. Snoopy Avatar answered Sep 07 '25 20:09

Dr. Snoopy


TensorFlow operations come packaged with a list of devices they can execute on and a list of associated priorities.

For example, a convolution is very conducive to computation on a GPU; but can still be done on a CPU whereas scalar additions should definitely be done on a CPU. You can override this selection using tf.Device and the key attached to the device of interest.

like image 24
mcatoen Avatar answered Sep 07 '25 20:09

mcatoen