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 use Python and TensorFlow to implement YOLO object detection?
- How can I access the 'inputs' attribute in the 'tensorflow_estimator.python.estimator.api._v2.estimator' module?
- How can I check the compatibility of different versions of Python and TensorFlow?
- How can I use TensorFlow Lite with XNNPACK in Python?
- How do I uninstall Python TensorFlow?
- How can I use Python and TensorFlow to handle illegal hardware instructions in Zsh?
- How can I use XGBoost, Python, and Tensorflow together for software development?
- How can I use Python and TensorFlow to create an XOR gate?
See more codes...