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 theconfig
parameter 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?
- ¿Cómo implementar reconocimiento facial con TensorFlow y Python?
- How can I check the compatibility of different versions of Python and TensorFlow?
- How do I uninstall Python TensorFlow?
- How do I check which version of TensorFlow I am using with Python?
- How can I use Python and TensorFlow together?
- How do I use Python TensorFlow 1.x?
- How do I use Python and TensorFlow Placeholders?
- How can I use Python and TensorFlow to handle illegal hardware instructions in Zsh?
- How can I compare and contrast Python TensorFlow and PyTorch?
See more codes...