python-tensorflowHow can I use TensorFlow without a GPU in Python?
TensorFlow can be used without a GPU in Python by using the CPU as the device for computation. To do this, you must set the device parameter of the tf.Session() to /cpu:0 when creating the TensorFlow session.
Example code
import tensorflow as tf
# Create the session
sess = tf.Session(config=tf.ConfigProto(device_count={'GPU': 0}))
# Run computation
result = sess.run(...)
Code explanation
import tensorflow as tf: imports the TensorFlow library.tf.Session(): creates the session with theconfigparameter set totf.ConfigProto(device_count={'GPU': 0})to disable the GPU and use the CPU instead.sess.run(...): runs the computation.
Helpful links
More of Python Tensorflow
- How do I resolve a SymbolAlreadyExposedError when the symbol "zeros" is already exposed as () in TensorFlow Python util tf_export?
- How can I check the compatibility of different versions of Python and TensorFlow?
- How can I use TensorFlow Lite with XNNPACK in Python?
- How can I troubleshoot a TensorFlow Python Framework ResourceExhaustedError graph execution error?
- How can I use Python and TensorFlow to handle illegal hardware instructions in Zsh?
- How do I install Tensorflow with a Python wheel (whl) file?
- ¿Cómo implementar reconocimiento facial con TensorFlow y Python?
- How can I use YOLOv3 with Python and TensorFlow?
- How can I use Python and TensorFlow to implement YOLO object detection?
- How can I use Tensorflow 1.x with Python 3.8?
See more codes...