TensorFlow: How to verify that it is running on GPU

Toke Faurby picture Toke Faurby · Mar 1, 2017 · Viewed 13.2k times · Source

I am looking for a simple way of verifying that my TF graphs are actually running on the GPU.

PS. It would also be nice to verify that the cuDNN library is used.

Answer

pfredriksen picture pfredriksen · Mar 1, 2017

There are several ways to view op placement.

  1. Add RunOptions and RunMetadata to the session call and view the placement of ops and computations in Tensorboard. See code here: https://www.tensorflow.org/get_started/graph_viz

  2. Specify the log_device_placement option in a session ConfigProto. This logs to console which device the operations are placed on. https://www.tensorflow.org/api_docs/python/tf/ConfigProto

  3. View GPU usage in the terminal using nvidia-smi.