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 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 do I install TensorFlow using pip and PyPI?
- How can I use Python and TensorFlow to implement YOLO object detection?
- How can I use Python and TensorFlow to implement YOLOv4?
- How can I use XGBoost, Python, and Tensorflow together for software development?
- How can I install TensorFlow offline using Python?
- How do I update my Python TensorFlow library?
See more codes...