python-tensorflowHow do I disable the GPU in Python Tensorflow?
To disable the GPU in Python Tensorflow, you need to set the CUDA_VISIBLE_DEVICES
environment variable to an empty string. This can be done using the following code:
import os
os.environ["CUDA_VISIBLE_DEVICES"] = ""
This will disable the GPU and cause Tensorflow to run on the CPU.
The code consists of two parts:
import os
: This imports theos
module, which provides functions for interacting with the operating system.os.environ["CUDA_VISIBLE_DEVICES"] = ""
: This sets theCUDA_VISIBLE_DEVICES
environment variable to an empty string. This will cause Tensorflow to ignore any GPUs present on the system and run on the CPU.
Helpful links
More of Python Tensorflow
- How can I use Python and TensorFlow to handle illegal hardware instructions in Zsh?
- How do I uninstall 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 use YOLOv3 with Python and TensorFlow?
- ¿Cómo implementar reconocimiento facial con TensorFlow y Python?
- How can I convert a Tensor object to a list in Python using TensorFlow?
- How do I use the Xception model in TensorFlow with Python?
- How can I use TensorFlow Lite with XNNPACK in Python?
- How can I use XGBoost, Python, and Tensorflow together for software development?
- How do I use TensorFlow 1.x with Python?
See more codes...